Class

HTMLForm

Package: Builder\Form Copyright: © 2005-2019 PHPBoost License: GNU/GPL-3.0 Author: Regis VIARRE crowkait@phpboost.com Version: PHPBoost 5.2 - last update: 2018 11 28 Since: PHPBoost 3.0 - 2009 04 28 Contributor: Julien BRISWALTER j1.seth@phpboost.com Contributor: Arnaud GENET elenwii@phpboost.com Located at: builder/form/HTMLForm.class.php

This class enables you to handle all the operations regarding forms. Indeed, you build a form using object components (fieldsets, fields, buttons) and it's able to display, to retrieve the posted values and also validate the entered data from constraints you define. The validation is done in PHP when the form is received, but also in live thanks to Javascript (each field is validated when it looses the focus and the whole form is validated when the user submits it).

HTMLForm implements HTMLElement
Methods summary
public
# __construct( string $html_id, string $target = '', boolean $enable_captcha_protection = true )

Constructs a HTMLForm object

public
public
# add_fieldset( FormFieldset $fieldset )

Adds fieldset in the form

public
# add_constraint( FormConstraint $constraint )

Adds a constraint on the form. This kind of constraints are rules regarding several fields.

public
# add_button( FormButton $button )

Adds a button to the form

public mixed
# get_value( string $field_id, $default_value = null )

Returns the value of a form field.

public Boolean
# field_is_disabled( string $field_id )

Returns true if field is disabled

public mixed
# has_field( string $field_id )

Returns true if the $field_id is in the form.

public
# get_field_by_id( $field_id )
public Template
# display( )

Displays the form

public boolean
# validate( )

Validates the form from all its constraints. If the constraints are satisfied, the validation errors will be displayed at the top of the form.

public
# set_html_id( string $html_id )

Sets the form's HTML id

public
public
# set_target( string $target )

Sets the form's target

public
# set_css_class( string $css_class )

Sets the form's CSS class

public
# set_method( string $method )

Sets the HTTP method with which the form will be submited

public
# set_template( Template $template )

Sets the template to use to display the form. If this method is not called, a default template will be used (

/template/default/framework/builder/form/Form.tpl

).

Constants summary
string HTTP_METHOD_POST
# 'post'
string HTTP_METHOD_GET
# 'get'
string SMALL_CSS_CLASS
# 'fieldset-mini'
string NORMAL_CSS_CLASS
# 'fieldset-content'