classname: htmlobject_formbuilder
extends: htmlobject_form
Formbuilder
@package htmlobjects
@author Alexander Kuballa [akuballa@users.sourceforge.net]
@copyright Copyright (c) 2008 - 2010, Alexander Kuballa
@license BSD License (see LICENSE.TXT)
@version 1.0
filename: htmlobject.formbuilder.class.php
Methods
Attributes
topattribute: box_css
access: public
default:
topaccess: public
default:
htmlobject_box
Css class for boxes @access public @var string
attribute: display_errors
access: public
default:
topaccess: public
default:
true
Display errors inline @access public @var bool
attribute: request_filter
access: public
default:
topaccess: public
default:
array( array( 'pattern' => '~\r\n~', 'replace' => "\n"), array( 'pattern' => '~<
Request filter for form elements
@access public
@var array
$form = new htmlobject_formbuilder($htmlobject);
$form->request_filter = array(
array ( 'pattern' => '~\r\n~', 'replace' => '\n'),
);
# disable filter
$form->request_filter = array();
attribute: value_filter
access: public
default:
access: public
default:
array( array( 'pattern' => '&', 'replace' => '&
Value filter for form elements
uses str_replace
@access public
@var array
$form = new htmlobject_formbuilder($htmlobject);
$form->value_filter = array(
array ( 'pattern' => '<', 'replace' => '<'),
);
# disable filter
$form->value_filter = array();
Methods
topfunction: __construct
params:
topparams:
$htmlobject
Constructor @access public @param htmlobject $htmlobject
function: init
topInit Formbuilder @access public
function: add
params:
topparams:
$data $key = null
Add additional content
@access public
@param array $data
@param dummy $key set for compatibility
$html = new htmlobject('path_to_htmlobjects');
$data['name']['label'] = 'Name';
$data['name']['required'] = true;
// static
// element will not be returned by get_request()
// if false element will trigger submited
// if true element will be ignored
$data['name']['static'] = false;
// validation
$data['name']['validate']['regex'] = '/^[a-z0-9~._-]+$/i';
$data['name']['validate']['errormsg'] = 'string must be a-z0-9~._-';
// build object
$data['name']['object']['type'] = 'htmlobject_input';
$data['name']['object']['attrib']['type'] = 'text';
$data['name']['object']['attrib']['name'] = 'name';
$data['name']['object']['attrib']['value'] = 'somevalue';
$formbuilder = $html->formbuilder();
$formbuilder->add( $data );
// Actions
// no errors, do something
if(!$formbuilder->get_errors()) {
$values = $formbuilder->get_request();
print_r($values);
}
function: get_elements
params:
topparams:
$name = null
Get array of objects will return array($name => htmlobject_box) @access public @param string $name name of element @return array of objects
function: get_object
topGet form objects @access public @return htmlobject_form
function: get_string
topGet formbuilder as string @access public @return string
function: get_request
params:
topparams:
$name = null
Get request values as array @access public @param string $name name of input @return array|string
function: get_errors
params:
topparams:
$name = null
Get one or all errors return array('name' => 'errormsg', ...) or string 'errormsg' if param name is set or null if no error occured @access public @param string $name key of element @return string|array|null
function: get_static
params:
topparams:
$name = null
Get one or all static @access public @param string $name key of element @return string|array|null
function: set_error
params:
topparams:
$name $value
Set error by element name @access public @param string $name name of input @param string $value
function: set_label
params:
topparams:
$key $value
Set label @access public @param string $key key of element @param string $value
function: remove
params:
topparams:
$name
Remove element by name @access public @param string $name name of input
function: __set_request
topSet values from http request as array @access protected
function: __set_request_errors
topCheck $this->__data request Returns array of errors if request does not match given regex. Empty if no missmatch occured. @access protected @todo pregmatch for arrays
function: __set_elements_value
topSet elements value make sure data, request and request_errors are set first @access protected
function: __handle_htmlobject
params:
topparams:
$key $value
Handle htmlobject @access protected @param string $key @param string $value
function: __get_label
params:
params:
$key
Handle label @access protected @param string $key @return string
- htmlobject
- htmlobject_a
- htmlobject_base
- htmlobject_box
- htmlobject_button
- htmlobject_div
- htmlobject_form
- htmlobject_formbuilder
- htmlobject_iframe
- htmlobject_img
- htmlobject_input
- htmlobject_option
- htmlobject_request
- htmlobject_response
- htmlobject_select
- htmlobject_table
- htmlobject_tablebuilder
- htmlobject_tabmenu
- htmlobject_td
- htmlobject_template
- htmlobject_textarea
- htmlobject_tr