[ Index ]

PHP Cross Reference of Unnamed Project

title

Body

[close]

/admin/tool/lp/classes/form/ -> persistent.php (summary)

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: 275 lines (10 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 9 functions

  __construct()
  convert_fields()
  extra_validation()
  filter_data_for_persistent()
  get_default_data()
  get_data()
  get_persistent()
  get_submitted_data()
  validation()

Functions
Functions that are not part of a class:

__construct($action = null, $customdata = null, $method = 'post', $target = '',$attributes = null, $editable = true)   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

convert_fields(stdClass $data)   X-Ref
Convert some fields.

param: stdClass $data The whole data set.
return: stdClass The amended data set.

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: tool_lp\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



Generated: Thu Aug 11 10:00:09 2016 Cross-referenced by PHPXref 0.7.1