Jeff PHP framework
0.99
Modular, extensible, OOP, MVC, lightweight php framework designed to ease the programmers in the development of web applications.
|
Class used to manage forms. More...
Public Member Functions | |
__construct ($method, $name, $opts=null) | |
Constructs a form instance. | |
captcha ($opts=null) | |
Captcha field (image and input field) | |
ccaptcha ($opts=null) | |
Captcha complete field (label, image and input field) | |
ccheckbox ($name, $checked, $value, $label, $opts=null) | |
Complete checkbox form element (label and input element) | |
cform () | |
Form close tag. | |
checkbox ($name, $checked, $value, $opts=null) | |
Checkbox form element. | |
checkCaptcha () | |
Captcha code check. | |
checkRequired () | |
Checks if the required fields have been filled. | |
cinput ($name, $type, $value, $label, $opts) | |
Complete form input element (label and input field) | |
cinput_date ($name, $value, $label, $opts) | |
Complete form date input element (label and input field) | |
cinput_datetime ($name, $value, $label, $opts) | |
Complete form datetime input element (label and input field) | |
cinput_file ($name, $value, $label, $opts=null) | |
Complete form input file element. | |
cmulticheckbox ($name, $checked, $values, $label, $opts=null) | |
Complete multi checkbox form elements (label and elements) | |
cradio ($name, $value, $data, $default, $label, $opts=null) | |
Complete form radio button (label and input element) | |
cselect ($name, $value, $data, $label, $opts=null) | |
Complete form select element (label and select element) | |
ctextarea ($name, $value, $label, $opts=null) | |
Complete form textarea element (label and textarea) | |
fieldset ($legend, $content, $opts=null) | |
Fieldset element. | |
free () | |
Deletes the session array used to save and load submitted data. | |
freeInput ($cleft, $cright, $opts=null) | |
Custom content formatted as a form element (label and field) | |
hidden ($name, $value, $opts=null) | |
Hidden field. | |
input ($name, $type, $value, $opts=null) | |
Form input element. | |
input_file ($name, $value, $opts=null) | |
Form input file element. | |
label ($text) | |
Label preparation. | |
load ($noerror=false) | |
Loads the submitted data previously saved to session. | |
multiplecheckbox ($name, $checked, $values, $opts=null) | |
Multi checkbox form elements. | |
radio ($name, $value, $data, $default, $opts) | |
Form radio button. | |
retvar ($name, $dft=null) | |
Retrieves the value of a variable loaded from session (and so previously submitted) | |
save () | |
Saves submitted data to session. | |
select ($name, $selected, $data, $opts) | |
Select form element. | |
setRequired ($required) | |
Sets the required fields. | |
sform ($action, $required, $opts=null) | |
Form open tag. | |
textarea ($name, $value, $opts) | |
Textarea form element. | |
uploadFile ($name, $valid_extension, $path, $link_error, $opts) | |
Management of form file uploads. | |
uploadImage ($name, $valid_extension, $path, $link_error, $opts) | |
Uploads the submitted image to the given directory. | |
Private Member Functions | |
checkExtension ($filename, $valid_extension) | |
Checks if the file extension is allowed. | |
generateFormToken () | |
CSRF token generation. | |
prepareView ($name, $l, $d, $req, $tadd, $opts=null) | |
Prepare the form element view. | |
setFileName ($name, $path, $prefix) | |
Sets the upload file name. | |
upload ($tmp_file, $filename, $path) | |
Upload a file to the given directory. | |
verifyFormToken () | |
CSRF token verification. | |
Private Attributes | |
$_method | |
form method (post or get) | |
$_name | |
form name and id | |
$_registry | |
the registry singleton instance | |
$_requestVars | |
Array containing the submitted data. | |
$_validation | |
whether to add javascript validation or not | |
$_view | |
a view instance |
Class used to manage forms.
Definition at line 30 of file form.class.php.
form::__construct | ( | $ | method, |
$ | name, | ||
$ | opts = null |
||
) |
Constructs a form instance.
string | $method | form method: post or get |
string | $name | form name and id |
array | $opts | associative array of options:
|
Definition at line 73 of file form.class.php.
form::captcha | ( | $ | opts = null | ) |
Captcha field (image and input field)
array | $opts | associative array of options:
|
Definition at line 275 of file form.class.php.
form::ccaptcha | ( | $ | opts = null | ) |
Captcha complete field (label, image and input field)
array | $opts | associative array of options:
|
Definition at line 257 of file form.class.php.
form::ccheckbox | ( | $ | name, |
$ | checked, | ||
$ | value, | ||
$ | label, | ||
$ | opts = null |
||
) |
Complete checkbox form element (label and input element)
string | $name | field name |
bool | $checked | whether to check the field or not |
mixed | $value | field value |
mixed | $label | field label |
mixed | $opts | associative array of options:
|
Definition at line 795 of file form.class.php.
form::cform | ( | ) |
form::checkbox | ( | $ | name, |
$ | checked, | ||
$ | value, | ||
$ | opts = null |
||
) |
Checkbox form element.
string | $name | field name |
bool | $checked | whether to check the field or not |
mixed | $value | field value |
mixed | $opts | associative array of options:
|
Definition at line 820 of file form.class.php.
Captcha code check.
Definition at line 291 of file form.class.php.
form::checkExtension | ( | $ | filename, |
$ | valid_extension | ||
) | [private] |
Checks if the file extension is allowed.
string | $filename | file name |
array | $valid_extension | list of valid extensions |
Definition at line 1242 of file form.class.php.
Checks if the required fields have been filled.
Definition at line 197 of file form.class.php.
form::cinput | ( | $ | name, |
$ | type, | ||
$ | value, | ||
$ | label, | ||
$ | opts | ||
) |
Complete form input element (label and input field)
string | $name | field name |
string | $type | input type |
mixed | $value | field value |
mixed | $label | field label |
mixed | $opts | associative array of options:
|
Definition at line 475 of file form.class.php.
form::cinput_date | ( | $ | name, |
$ | value, | ||
$ | label, | ||
$ | opts | ||
) |
Complete form date input element (label and input field)
string | $name | field name |
string | $value | field value |
mixed | $label | field label |
mixed | $opts | associative array of options:
|
Definition at line 496 of file form.class.php.
form::cinput_datetime | ( | $ | name, |
$ | value, | ||
$ | label, | ||
$ | opts | ||
) |
Complete form datetime input element (label and input field)
string | $name | field name |
string | $value | field value |
mixed | $label | field label |
mixed | $opts | associative array of options:
|
Definition at line 540 of file form.class.php.
form::cinput_file | ( | $ | name, |
$ | value, | ||
$ | label, | ||
$ | opts = null |
||
) |
Complete form input file element.
string | $name | field name |
string | $value | field value |
mixed | $label | field label |
mixed | $opts | associative array of options:
|
Definition at line 910 of file form.class.php.
form::cmulticheckbox | ( | $ | name, |
$ | checked, | ||
$ | values, | ||
$ | label, | ||
$ | opts = null |
||
) |
Complete multi checkbox form elements (label and elements)
string | $name | field name |
array | $checked | array containing the checked items |
array | $values | array of items in the form array(array('label'=>'item_label', 'value'=>'item_value')) |
mixed | $label | form label |
mixed | $opts | associative array of options:
|
Definition at line 847 of file form.class.php.
form::cradio | ( | $ | name, |
$ | value, | ||
$ | data, | ||
$ | default, | ||
$ | label, | ||
$ | opts = null |
||
) |
Complete form radio button (label and input element)
string | $name | field name |
mixed | $value | field value |
array | $data | radio choices in the array form array('value'=>'label') |
mixed | $default | default choice selected |
mixed | $label | field label |
mixed | $opts | associative array of options:
|
Definition at line 657 of file form.class.php.
form::cselect | ( | $ | name, |
$ | value, | ||
$ | data, | ||
$ | label, | ||
$ | opts = null |
||
) |
Complete form select element (label and select element)
string | $name | field name |
mixed | $value | field value |
array | $data | select options in the array form array('value'=>'label') |
mixed | $label | field label |
mixed | $opts | associative array of options:
|
Definition at line 716 of file form.class.php.
form::ctextarea | ( | $ | name, |
$ | value, | ||
$ | label, | ||
$ | opts = null |
||
) |
Complete form textarea element (label and textarea)
string | $name | field name |
string | $value | field value |
mixed | $label | field label |
mixed | $opts | associative array of options:
|
Definition at line 585 of file form.class.php.
form::fieldset | ( | $ | legend, |
$ | content, | ||
$ | opts = null |
||
) |
Fieldset element.
string | $legend | the legend content |
string | $content | the fieldset content |
mixed | $opts | associative array of options:
|
Definition at line 311 of file form.class.php.
form::free | ( | ) |
Deletes the session array used to save and load submitted data.
Definition at line 174 of file form.class.php.
form::freeInput | ( | $ | cleft, |
$ | cright, | ||
$ | opts = null |
||
) |
Custom content formatted as a form element (label and field)
string | $cleft | left content (as a label) |
string | $cright | right content (as an input) |
mixed | $opts | associative array of options:
|
Definition at line 400 of file form.class.php.
form::generateFormToken | ( | ) | [private] |
CSRF token generation.
Definition at line 99 of file form.class.php.
form::hidden | ( | $ | name, |
$ | value, | ||
$ | opts = null |
||
) |
Hidden field.
string | $name | field name |
mixed | $value | field value |
array | $opts | associative array of options:
|
Definition at line 351 of file form.class.php.
form::input | ( | $ | name, |
$ | type, | ||
$ | value, | ||
$ | opts = null |
||
) |
Form input element.
string | $name | the field name |
string | $type | the input type (text, password, checkbox, ...) |
mixed | $value | the input value |
mixed | $opts | associative array of options:
|
Definition at line 433 of file form.class.php.
form::input_file | ( | $ | name, |
$ | value, | ||
$ | opts = null |
||
) |
Form input file element.
string | $name | field name |
string | $value | field value |
mixed | $opts | associative array of options:
|
Definition at line 934 of file form.class.php.
form::label | ( | $ | text | ) |
Label preparation.
mixed | $text | label text. Possible values are:
|
Definition at line 329 of file form.class.php.
form::load | ( | $ | noerror = false | ) |
Loads the submitted data previously saved to session.
bool | $noerror | whether to loads data even if no error occurs |
Definition at line 127 of file form.class.php.
form::multiplecheckbox | ( | $ | name, |
$ | checked, | ||
$ | values, | ||
$ | opts = null |
||
) |
Multi checkbox form elements.
string | $name | field name |
array | $checked | array containing the checked items |
array | $values | array of items in the form array(array('label'=>'item_label', 'value'=>'item_value')) |
mixed | $opts | associative array of options:
|
Definition at line 872 of file form.class.php.
form::prepareView | ( | $ | name, |
$ | l, | ||
$ | d, | ||
$ | req, | ||
$ | tadd, | ||
$ | opts = null |
||
) | [private] |
Prepare the form element view.
string | $name | field name |
mixed | $l | field label |
mixed | $d | field label description |
bool | $req | whether the field is required or not |
string | $tadd | text added after the input element |
mixed | $opts | associative array of options:
|
Definition at line 373 of file form.class.php.
form::radio | ( | $ | name, |
$ | value, | ||
$ | data, | ||
$ | default, | ||
$ | opts | ||
) |
Form radio button.
string | $name | field name |
mixed | $value | field value |
array | $data | radio choices in the array form array('value'=>'label') |
mixed | $default | default choice selected |
mixed | $opts | associative array of options:
|
Definition at line 682 of file form.class.php.
form::retvar | ( | $ | name, |
$ | dft = null |
||
) |
Retrieves the value of a variable loaded from session (and so previously submitted)
string | $name | the field name |
mixed | $dft | deafult value if variable was not loaded |
Definition at line 163 of file form.class.php.
form::save | ( | ) |
form::select | ( | $ | name, |
$ | selected, | ||
$ | data, | ||
$ | opts | ||
) |
Select form element.
string | $name | field name |
mixed | $value | field value |
array | $data | select options in the array form array('value'=>'label') |
mixed | $opts | associative array of options:
|
Definition at line 748 of file form.class.php.
form::setFileName | ( | $ | name, |
$ | path, | ||
$ | prefix | ||
) | [private] |
Sets the upload file name.
If another file with the same name exists in the upload directory adds .1, .2, etc.. at the end of the name
string | $name | file name |
string | $path | absolute path of the upload directory |
string | $prefix | file name prefix |
Definition at line 1221 of file form.class.php.
form::setRequired | ( | $ | required | ) |
Sets the required fields.
string | $required | comma separated list of required fields |
Definition at line 186 of file form.class.php.
form::sform | ( | $ | action, |
$ | required, | ||
$ | opts = null |
||
) |
Form open tag.
string | $action | form action attribute |
string | $required | comma separated list of required fields |
mixed | $opts | Associative array:
|
Definition at line 223 of file form.class.php.
form::textarea | ( | $ | name, |
$ | value, | ||
$ | opts | ||
) |
Textarea form element.
string | $name | field name |
string | $value | field value |
mixed | $opts | associative array of options:
|
Definition at line 615 of file form.class.php.
form::upload | ( | $ | tmp_file, |
$ | filename, | ||
$ | path | ||
) | [private] |
Upload a file to the given directory.
string | $tmp_file | name of the temporary file |
string | $filename | name of the file saved to filesystem |
string | $path | path of the saving directory |
Definition at line 1262 of file form.class.php.
form::uploadFile | ( | $ | name, |
$ | valid_extension, | ||
$ | path, | ||
$ | link_error, | ||
$ | opts | ||
) |
Management of form file uploads.
Method for managing files via the upload form. If a new file is uploaded the old file is deleted.
The old file can also be deleted without uploading a new one. If no file is uploaded and the deletion checkbox in the input file element is unchecked then all stands as is.
string | $name | field name |
array | $valid_extension | list of valid extensions |
string | $path | absolute path to the upload directory |
string | $link_error | redirection url in case of error |
mixed | $opts | associative array of options:
|
Definition at line 979 of file form.class.php.
form::uploadImage | ( | $ | name, |
$ | valid_extension, | ||
$ | path, | ||
$ | link_error, | ||
$ | opts | ||
) |
Uploads the submitted image to the given directory.
Method for managing images via the upload form. If a new file is uploaded the old file is deleted.
The old file can also be deleted without uploading a new one. If no file is uploaded and the deletion checkbox in the input file element is unchecked then all stands as is.
string | $name | field name |
array | $valid_extension | list of valid extensions |
string | $path | absolute path to the upload directory |
string | $link_error | redirectino url in case of error |
mixed | $opts | associative array of options:
|
Definition at line 1090 of file form.class.php.
form::verifyFormToken | ( | ) | [private] |
CSRF token verification.
Definition at line 110 of file form.class.php.
form::$_method [private] |
form method (post or get)
Definition at line 45 of file form.class.php.
form::$_name [private] |
form name and id
Definition at line 50 of file form.class.php.
form::$_registry [private] |
the registry singleton instance
Definition at line 35 of file form.class.php.
form::$_requestVars [private] |
Array containing the submitted data.
Definition at line 60 of file form.class.php.
form::$_validation [private] |
whether to add javascript validation or not
Definition at line 55 of file form.class.php.
form::$_view [private] |
a view instance
Definition at line 40 of file form.class.php.