Field Class Tree & Validation Functions - Richard1320/php-form-processor GitHub Wiki
The plugin was built with extensions in mind. This allows you to create your own custom fields displays and validation methods.
Everything extends from the fieldBase
class.
Extends: N/A
Field Types: N/A
Template: N/A
Validation: is valid amount
Checks to see if the type of the value submitted is an array or string. Fields that have multiple
enabled can be either strings or arrays. Fields that have multiple
disabled and type is not checkbox can only be a string.
Validation: is filled in
Checks to see if the field is empty.
Note: This check is only run if the required parameter on the field is true.
Extends: fieldBase
Field Types: textarea
Template: textarea.tpl.php
Extends: fieldBase
Field Types: text, email, password, anything <input>
that is not file, radio or checkbox. Check input types for a full list
Template: input_text.tpl.php
Validation: max length
Checks to see if the submitted value exceeds the number of characters allowed.
Note: This check is only run if the maxlength parameter on the field is set.
Validation: email format
Runs value through filter_var($value, FILTER_VALIDATE_EMAIL)
to check for basic email structure.
Note: This check is only run if the type parameter on the field is set to email.
Extends: fieldBase
Field Types: file
Template: input_file.tpl.php
Validation: file exists
Checks the server to see if the file is actually there.
Validation: maxsize
Checks to see if the filesize is bigger than allowed.
Note: This amount is in bytes. 1MB = 1048600 bytes.
Validation: file extension
Checks if the file uploaded has the correct extension.
Warning: This only checks the filename extension. This does not check if the file is actually the specified type. A exe file renamed to a txt extension can bypass this check. If you allow the general public to upload, you will need further checks.
Extends: fieldInputFile
Field Types: file
Template: N/A (Inherit)
Validation: is image
Checks to see if the file is an image.
This runs the file through exif_imagetype
so you can be relatively sure that it is an actual image file.
Extends: fieldBase
Field Types: N/A
Template: N/A
Validation: is allowed value
Cross-references the submitted value with the original list of options.
Note If you're adding more options using JavaScript, this check may fail. In this situation, I recommend you enter in the entire pool as options at the start and use JavaScript to remove the options you need to hide.
Extends: fieldOptionsList
Field Types: select
Template: select.tpl.php
Extends: fieldOptionsList
Field Types: radio, checkbox
Template: input_radio_checkbox.tpl.php