| string |
$id |
Unique name to identify the control in the form. The control's name attribute will be the same as the id attribute! This is the name to be used when referring to the control's value in the POST/GET superglobals, after the form is submitted. This is also the name of the variable to be used in custom template files, in order to display the control. // in a template file, in order to print the generated HTML
// for a control named "my_text", one would use:
echo $my_text;
|
| array |
$attributes |
(Optional) An array of attributes valid for input controls (size, readonly, style, etc) Must be specified as an associative array, in the form of attribute => value. // setting the "readonly" attribute
$obj = $form->add(
'text',
'my_text',
'',
array(
'readonly' => 'readonly'
)
);
There's a special data-prefix attribute that you can use to add uneditable
prefixes to input fields (text, images, or plain HTML), as seen in the image below. It works by injecting an absolutely positioned element into the DOM, right after the parent element, and then positioning it on the left side of the parent element and adjusting the width and the left padding of the parent element, so it looks like the prefix is part of the parent element. If the prefix is plain text or HTML code, it will be contained in a <div> tag
having the class Zebra_Form_Input_Prefix; if the prefix is a path to an
image, it will be an <img> tag having the class Zebra_Form_Input_Prefix. For anything other than plain text, you must use CSS to set the width and
height of the prefix, or it will not be correctly positioned because when the image
is not cached by the browser the code taking care of centering the image will
be executed before the image is loaded by the browser and it will not know the
image's width and height! 
// add simple text
// style the text through the Zebra_Form_Input_Prefix class
$form->add('text', 'my_text', '', array('data-prefix' => 'http://'));
$form->add('text', 'my_text', '', array('data-prefix' => '(+1 917)'));
// add images
// set the image's width and height through the img.Zebra_Form_Input_Prefix class
// in your CSS or the image will not be correctly positioned!
$form->add('text', 'my_text', '', array('data-prefix' => 'img:path/to/image'));
// add html - useful when using sprites
// again, make sure that you set somewhere the width and height of the prefix!
$form->add('text', 'my_text', '', array('data-prefix' => '<div class="sprite image1"></div>'));
$form->add('text', 'my_text', '', array('data-prefix' => '<div class="sprite image2"></div>'));
See set_attributes() on how to set attributes, other than through the constructor. The following attributes are automatically set when the control is created and should not be altered manually:
type, id, name, value, class |