Class: Zebra_Form_Note
source file: /includes/Note.php
Class Overview
XSS_Clean
|
--Zebra_Form_Control
|
--Zebra_Form_Note
Class for notes attached to controls
Author(s):
Copyright:
- (c) 2006 - 2013 Stefan Gabos
Class methods
constructor __construct()
void
__construct (
string
$id
,
string
$attach_to
,
string
$caption
,
[
array
$attributes
= '']
)
Adds a "note" to the form, attached to a control.
Do not instantiate this class directly! Use the add() method instead!
// create a new form
// add a text control to the form
$obj = $form->add('text', 'my_text');
// attach a note to the textbox control
$form->add('note', 'note_my_text', 'my_text', 'Enter some text in the field above');
// don't forget to always call this method before rendering the form
if ($form->validate()) {
// put code here
}
// output the form using an automatically generated template
$form->render();
Parameters:
| string |
$id |
Unique name to identify the control in the form. This is the name of the variable to be used in the template file, containing the generated HTML for the control. // in a template file, in order to print the generated HTML
// for a control named "my_note", one would use:
echo $my_note;
|
| string |
$attach_to |
The id attribute of the control to attach the note to. Notice that this must be the "id" attribute of the control you are attaching
the label to, and not the "name" attribute! This is important as while most of the controls have their id attribute set to the same value as their name attribute, for checkboxes, selects and radio buttons this is different. Exception to the rule: Just like in the case of labels, if you want a master note, a note that is attached to a group of checkboxes/radio buttons rather than individual controls, this attribute must instead refer to the name of the controls (which, for groups of checkboxes/radio buttons, is one and the same). |
| string |
$caption |
Content of the note (can be both plain text and/or HTML) |
| array |
$attributes |
(Optional) An array of attributes valid for div elements (style, etc) Must be specified as an associative array, in the form of attribute => value. // setting the "style" attribute
$obj = $form->add(
'note',
'note_my_text',
'my_text',
array(
'style' => 'width:250px'
)
);
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: class |
Top
method toHTML()
string
toHTML (
)
Generates the control's HTML code.
This method is automatically called by the render() method!
Tags:
| return: |
The control's HTML code |
Top