Class: Zebra_Form_Image
source file: /includes/Image.php
Class Overview
XSS_Clean
|
--Zebra_Form_Control
|
--Zebra_Form_Image
Class for image controls.
Author(s):
Copyright:
- (c) 2006 - 2013 Stefan Gabos
Class methods
constructor __construct()
void
__construct (
string
$id
,
string
$src
,
[
array
$attributes
= '']
)
Adds an <input type="image"> control to the form.
Do not instantiate this class directly! Use the add() method instead!
// create a new form
// add an image control to the form
$obj = $form->add('image', 'my_image', 'path/to/image');
// 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. 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_image", one would use:
echo $my_image;
|
| string |
$src |
(Optional) Path to an image file. |
| 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 "alt" attribute
$obj = $form->add(
'image',
'my_image',
'path/to/image',
array(
'alt' => 'Click to submit form'
)
);
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, src, 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