Class

AbstractFormField

Abstract Package: Builder\Form\field Copyright: © 2005-2019 PHPBoost License: GNU/GPL-3.0 Author: Benoit SAUTEL ben.popeye@phpboost.com Version: PHPBoost 5.2 - last update: 2018 05 31 Since: PHPBoost 3.0 - 2010 01 08 Contributor: Julien BRISWALTER j1.seth@phpboost.com Contributor: Arnaud GENET elenwii@phpboost.com Located at: builder/form/field/AbstractFormField.class.php

Abstract class that proposes a default implementation for the FormField interface.

AbstractFormField implements FormField
Methods summary
protected
# __construct( string $id, string $label, mixed $value, array $field_options = array(), array $constraints = array() )

Constructs and set parameters to the field. The specific parameters of this abstract class (common with many fields) are the following:

  • description at which you must associate the description of the field
  • class which corresponds to the HTML class of the field
  • required which tells whether this field must be completed. If it's the case, it will display a * beside the label and will add a non empty constraint to the constraints.

None of these parameters is required.

public string
# get_id( )

Returns the id.

public
# set_id( string $id )

Sets the id

public
public
# set_form_id( string $form_id )

Sets the id prefix

public
# set_fieldset_id( $fieldset_id )

Sets the if of the fieldset which contains the field

public string
# get_label( )

Returns the label

public
# set_label( string $label )

Sets the label

public string
# get_description( )

Returns the description

public
# set_description( string $description )

Sets the description

public mixed
# get_value( )
public
# set_value( string $value )

Sets the value

public true
# is_required( )

Tells whether the field is required

public
# set_required( boolean $required )

Changes the fact that the field is required or not.

public boolean
# validate( )

Validates the field by cheching if all the constraints are satisfied.

public
# get_validation_error_message( )

Returns validation error message.

public
# set_validation_error_message( string $error_message )

Set the validation error message.

public
# retrieve_value( )

Tries to retrieve the value in the HTTP request's parameters.

public string
# get_html_id( )

Returns the effective HTML id.

public
# add_constraint( FormFieldConstraint $constraint )

Adds a constraint to the field constraints.

public
# add_form_constraint( FormConstraint $constraint )

Add javascript code on the onblur field parameter that makes validation

public boolean
# has_constraints( )

Return true if the field has one or more constraints, false otherwise.

public string
# get_js_validations( )

Returns the javascript onsubmit code.

public
public
# add_event( $event, $handler )
protected
# compute_options( array & $field_options )
protected
protected
protected
# set_css_class( $css_class )
protected
protected
# set_css_field_class( $css_field_class )
protected
protected
# set_css_form_field_class( $css_form_field_class )
public boolean
# is_disabled( )

Tells whether the field is disabled

public
# disable( )

Disabled the field

public
# enable( )

Enables the field

protected
# set_disabled( $disabled )
public
public
# set_readonly( $readonly )
public
public
# set_hidden( $hidden )
public
public
# set_pattern( $pattern )
public
public
# set_placeholder( $placeholder )
public
# set_template( Template $template )
protected Template
abstract protected Template
protected
Methods inherited from HTMLElement
display()
Properties summary
protected string $id
# ''
protected string $label
# ''
protected string $description
# ''
protected string $value
# null
protected boolean $disabled
# false
protected boolean $hidden
# false
protected boolean $readonly
# false
protected string $css_class
# ''
protected string $css_field_class
# ''
protected string $css_form_field_class
# ''
protected string $required
# false
protected string $pattern
# ''
protected string $placeholder
# ''
protected string $validation_error_message
# ''
protected FormFieldConstraint[] $constraints
# array()
protected FormConstraint[] $form_constraints
# array()
protected Template $template
# null
protected string[string] $events
# array()