
Public Member Functions | |
| __construct ($data=null, $extra=array(), $label_suffix=null) | |
| initFields ($extra=array()) | |
| addPrefix ($field_name) | |
| isValid () | |
| clean () | |
| failed () | |
| initial ($name) | |
| render_top_errors () | |
| get_top_errors () | |
| render_p () | |
| render_ul () | |
| render_table () | |
| __get ($prop) | |
| field ($key) | |
| current () | |
| key () | |
| next () | |
| rewind () | |
| valid () | |
| offsetUnset ($index) | |
| offsetSet ($index, $value) | |
| offsetGet ($index) | |
| offsetExists ($index) | |
Public Attributes | |
| $fields = array() | |
| $prefix = '' | |
| $id_fields = 'id_%s' | |
| $data = array() | |
| $cleaned_data = array() | |
| $errors = array() | |
| $is_bound = false | |
| $f = null | |
| $label_suffix = ':' | |
Protected Member Functions | |
| htmlOutput ($normal_row, $error_row, $row_ender, $help_text_html, $errors_on_separate_row) | |
Protected Attributes | |
| $is_valid = null | |
This class is used to generate a form. You basically build it the same way you build a model.
The form handling is heavily inspired by the Django form handling.
| Pluf_Form::__construct | ( | $ | data = null, |
|
| $ | extra = array(), |
|||
| $ | label_suffix = null | |||
| ) |
| Pluf_Form::initFields | ( | $ | extra = array() |
) |
Reimplemented in Pluf_Form_Model.
| Pluf_Form::addPrefix | ( | $ | field_name | ) |
Add the prefix to the form names.
| string | Field name. |
| Pluf_Form::isValid | ( | ) |
Check if the form is valid.
It is also encoding the data in the form to be then saved. It is very simple as it leaves the work to the field. It means that you can easily extend this form class to have a more complex validation procedure like checking if a field is equals to another in the form (like for password confirmation) etc.
| array | Associative array of the request |
| Pluf_Form::clean | ( | ) |
Form wide cleaning function. That way you can check that if an input is given, then another one somewhere is also given, etc. If the cleaning is not ok, your method must throw a Pluf_Form_Invalid exception.
| Pluf_Form::failed | ( | ) |
Method just called after the validation if the validation failed. This can be used to remove uploaded files. $this->['cleaned_data'] will be available but of course not fully populated and with possible garbage due to the error.
| Pluf_Form::initial | ( | $ | name | ) |
Get initial data for a given field.
| string | Field name. |
| Pluf_Form::render_top_errors | ( | ) |
Get the top errors.
| Pluf_Form::get_top_errors | ( | ) |
Get the top errors.
| Pluf_Form::htmlOutput | ( | $ | normal_row, | |
| $ | error_row, | |||
| $ | row_ender, | |||
| $ | help_text_html, | |||
| $ | errors_on_separate_row | |||
| ) | [protected] |
Helper function to render the form.
See render_p() for a usage example.
Django Project (http://www.djangoproject.com/)
| string | Normal row. | |
| string | Error row. | |
| string | Row ender. | |
| string | Help text HTML. | |
| bool | Should we display errors on a separate row. |
| Pluf_Form::render_p | ( | ) |
Render the form as a list of paragraphs.
| Pluf_Form::render_ul | ( | ) |
Render the form as a list without the
| Pluf_Form::render_table | ( | ) |
Render the form as a table without
| Pluf_Form::__get | ( | $ | prop | ) |
Overloading of the get method.
The overloading is to be able to use property call in the templates.
| Pluf_Form::field | ( | $ | key | ) |
Get a given field by key.
| Pluf_Form::current | ( | ) |
Iterator method to iterate over the fields.
Get the current item.
| Pluf_Form::key | ( | ) |
| Pluf_Form::next | ( | ) |
| Pluf_Form::rewind | ( | ) |
| Pluf_Form::valid | ( | ) |
| Pluf_Form::offsetUnset | ( | $ | index | ) |
| Pluf_Form::offsetSet | ( | $ | index, | |
| $ | value | |||
| ) |
| Pluf_Form::offsetGet | ( | $ | index | ) |
| Pluf_Form::offsetExists | ( | $ | index | ) |
| Pluf_Form::$fields = array() |
The fields of the form.
They are the fully populated Pluf_Form_Field_* of the form. You define them in the initFields method.
| Pluf_Form::$prefix = '' |
Prefix for the names of the fields.
| Pluf_Form::$id_fields = 'id_%s' |
| Pluf_Form::$data = array() |
| Pluf_Form::$cleaned_data = array() |
| Pluf_Form::$errors = array() |
| Pluf_Form::$is_bound = false |
| Pluf_Form::$f = null |
| Pluf_Form::$label_suffix = ':' |
Pluf_Form::$is_valid = null [protected] |