Class HtmlFormBasic
- HtmlElement
- HtmlFormBasic
Direct known subclasses
Indirect known subclasses
License: GNU General Public License v2.0 only **********************************************************************************************
Brief:
Create html form elements
This class creates html form elements. Create an instance of an form element and set the input elements inline . The class supports setting all form elements and allows you to configure all attributes programatically. The parsed form object is returned as string.
Class: HtmlFormBasic
Code: $attrArray = array('class' => 'Classname');
Code:
// Get the Instance for a new form element and set an action attribute $form = new HtmlFormBasic('test.php'); // XHTML determines that the input elements are inline elements of a block element // so we need somthing like a div Block. In this example we use a fieldset $form->addFieldSet(); // we can define a label for the input element with reference ID $form->addLabel('Field_1', 'ID_1'); // set an input element like a text field. All valid types are supported // you can define further attributes as associative array and set as parameter in correct position $form->addSimpleInput('text', 'Input_1', 'ID_1', 'Value_1', $attrArray); // add a linebreak $form->linebreak(); // next label $form->addLabel('Radio_1', 'ID_2'); // next element is a radio button $form->addSimpleInput('radio', 'Radio_1', 'ID_2', 'Value_Radio'); // add a linebreak $form->linebreak(); // Define a select box $form->addSelect('Select_Name', 'ID_3', $attrArray); // now we can also specify an optiongroup $form->addOptionGroup('Group_1', 'ID_4', $attrArray); // define options $form->addOption('Option_Value_1', 'Option_Label_1'); $form->addOption('Option_Value_2', 'Option_Label_2'); $form->addOption('Option_Value_3', 'Option_Label_3'); // end of option group $form->closeOptionGroup(); // end of select box $form->closeSelect(); // add a linebreak $form->linebreak(); // example of a text area $form->addTextArea('Textarea', '4', '4', 'Input please ...', 'ID_5', $attrArray); // close open fieldset block $form->closeFieldSet(); // print the form echo $form->getHtmlForm();
Endcode
Endcode
Par: Example of an array with further attributes
Par: Example: Creating a form element
Located at htmlformbasic.php
Methods summary
public
|
#
__construct( string $action = null, string $id = null, string $method = 'get', string $event = null, string $script = null )
Constructor creates the element |
public
|
|
public
|
#
addSimpleInput( string $type, string $name, string $id = null, string $value = '', array $arrAttributes = null )
Add a input field with attribute properties. |
public
|
|
public
|
|
public
|
|
public
|
#
addOptionGroup( string $label, string $id = null, array $arrAttributes = null, boolean $disable = false )
Add an option group. |
public
|
|
public
|
#
addSimpleButton( string $name, string $type, string $value, string $id = null, string $link = null )
Adds a button to the form. |
public
|
#
addTextArea( string $name, integer $rows, integer $cols, string $text = '', string $id = null, array $arrAttributes = null, boolean $disable = false )
Add a text area. |
public
|
|
public
|
|
public
|
|
public
string
|
Methods inherited from HtmlElement
addAttribute()
,
addData()
,
addElement()
,
addHtml()
,
addParentElement()
,
closeParentElement()
,
getHtmlElement()
,
setAttributesFromArray()
Properties summary
Properties inherited from HtmlElement
$arrParentElements
,
$currentElement
,
$currentElementAttributes
,
$currentElementDataWritten
,
$htmlString
,
$mainElement
,
$mainElementAttributes
,
$mainElementWritten
,
$nesting
,
$parentFlag