See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 401]
Persistent form abstract.
Copyright: | 2015 Frédéric Massart - FMCorz.net |
License: | http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
File Size: | 320 lines (11 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
persistent:: (10 methods):
__construct()
convert_fields()
after_definition()
extra_validation()
filter_data_for_persistent()
get_default_data()
get_data()
get_persistent()
get_submitted_data()
validation()
Class: persistent - X-Ref
Persistent form abstract class.__construct($action = null, $customdata = null, $method = 'post', $target = '',$attributes = null, $editable = true, $ajaxformdata=null) X-Ref |
Constructor. The 'persistent' has to be passed as custom data when 'editing'. Note that in order for your persistent to be reloaded after form submission you should either override the URL to include the ID to your resource, or add the ID to the form fields. param: mixed $action param: mixed $customdata param: string $method param: string $target param: mixed $attributes param: bool $editable param: array $ajaxformdata |
convert_fields(stdClass $data) X-Ref |
Convert some fields. param: stdClass $data The whole data set. return: stdClass The amended data set. |
after_definition() X-Ref |
After definition hook. Automatically try to set the types of simple fields using the persistent properties definition. This only applies to hidden, text and url types. Groups are also ignored as they are most likely custom. return: void |
extra_validation($data, $files, array &$errors) X-Ref |
Define extra validation mechanims. The data here: - does not include {@link self::$fieldstoremove}. - does include {@link self::$foreignfields}. - was converted to map persistent-like data, e.g. array $description to string $description + int $descriptionformat. You can modify the $errors parameter in order to remove some validation errors should you need to. However, the best practice is to return new or overriden errors. Only modify the errors passed by reference when you have no other option. Do not add any logic here, it is only intended to be used by child classes. param: stdClass $data Data to validate. param: array $files Array of files. param: array $errors Currently reported errors. return: array of additional errors, or overridden errors. |
filter_data_for_persistent($data) X-Ref |
Filter out the foreign fields of the persistent. This can be overridden to filter out more complex fields. param: stdClass $data The data to filter the fields out of. return: stdClass. |
get_default_data() X-Ref |
Get the default data. This is the data that is prepopulated in the form at it loads, we automatically fetch all the properties of the persistent however some needs to be converted to map the form structure. Extend this class if you need to add more conversion. return: stdClass |
get_data() X-Ref |
Get form data. Conveniently removes non-desired properties and add the ID property. return: object|null |
get_persistent() X-Ref |
Return the persistent object associated with this form instance. return: \core\persistent |
get_submitted_data() X-Ref |
Get the submitted form data. Conveniently removes non-desired properties. return: object|null |
validation($data, $files) X-Ref |
Form validation. If you need extra validation, use {@link self::extra_validation()}. param: array $data param: array $files return: array |