public function checkToken ( $tokenFromUser)

Convert Date received in one format to another.
If the provided string is not corresponding to the format, don't change
anything.
Format used http://php.net/manual/en/datetime.createfromformat.php
@param string $inputDate The date to modify
@param string $inputFormat The input format of the date
@param string $outputFormat The output format of the date
@return string

public function csrf ( $val)

Set the csrf enable
@param integer $val The csrf check

public function csrfField ( $val)

Set the csrf token name
@param integer $val The csrf token name

public function debug ( $val)

Set the debug level
@param integer $val The debug value

public function fields ( $fields)

Save the array of fields into the structure.
Available :
- name : name of the field in the HTML page
- label : label written to the describe the field
- [titles] : text written in radio/checkboxes
- [defaults] : default values. Must be array for checkbox/select, and
string for others
- [type] : text, password, hidden, checkbox, select, radio, submit,
textarea
text by default
- [help] : The Help message (written below the field). Overwrited in
case of error
- [multiple] : Multiple selection are possible (if the type supports it)
- [group] : define a fieldset and define the title with groupe name
Warning : all the elements of the same group must be
consecutive !
- [readonly] : put a read-only flag on the field (the user see it but
can't interract on it. The value will be sent to next
page
- [mandatory] : boolean to add a red star at end of label
- [hidden] : hide the field (add a style='display:hidden' to the field)
- [maxlength] : the maximum length of the content of the field in chars
- [rows] : Number of rows
- [cols] : Number of columns
- [placeholder] : The text to be displayed in the placeholder
@param array $fields The fields to be displayed

public function fieldwidth ( $val)

Set the fieldwidth
@param integer $val The fieldwidth

public function formClass ( $val)

Set the formClass
@param integer $val The formClass

public function formTemplate ( $formTemplate)

Set the Form Templating to use.
Can be : Bootstrap3, Bootstrap4 (later Bulma)
@param string $formTemplate The template to use

public function getOldErrors ( $errors)

Get the stored errors if there is one. If there is no sorted errors,
return the errors provided as parameter
@param array $errors The values returned if there is no stored values
@return array The errors to use

public function getOldValues ( $values)

Get the stored values if there is one. If there is no stored values,
return the values provided as parameter
@param array $values The values returned if there is no stored values
@return array The values to use

public function getToken ()

Return the token generated in form

public function logging ( $loggingCallable, $loggingBasemsg="")

Set logging class an method
@param callable $loggingCallable The callable function. This method will
receive two params : the LOG level (LOG_ERROR...) and the message
@param string|null $loggingBasemsg The basemsg added at the beginning of
the log

public function method ( $val)

Return the fields in HTML code. If $values is provided, use it in place
of default values. In case of select boxes, $values are the selected
elements
$method is the method written in method field of <form>
@param string|null $method The method to use to transmit the form (POST,
GET)
@param array|null $values The default values of the fields
@param array|null $errors The fields to put in error with the associated
message

public function redirectIfError ( $values, $errors, $route, $url="")

If there is at least one error reported in $errors, save the old values
and the errors in the session, and redirect to the provided url.
If there is no error, do nothing
@param array $values The values of the fields filled by the user
@param array $errors The errors detected by a verify
@param object $route the route object
@param string|null $url The URL to redirect. If not provided, use the
$route->requestURL () method to found the calling page
Example :
$form = new \form ();
$form->logging (array ('\apps\general\controllers\logging', 'log'),
$authHTML["email"]);
$values = $form->values ();
$errors = $spaceObj->verify ($values);
$form->redirectIfError ($values, $errors, $route, "/admin/space/");
$spaceuuid = $spaceObj->spaceCreateConceal ($values["spacename"]);
$route->redirect ("/admin/space/");

public function saveValuesErrors ( $values, $errors=array ())

Save the values and errors to be displayed in the next page if the session
is available
Need the session to work
@param array $values The values of the fields filled by the user
@param array|null $errors The errors detected by a verify

public function saveValuesErrorsReset ()

Reset the saved values to provide a clean form next page
Need the session to work

public function titlewidth ( $val)

Set the titlewidth
@param integer $val The titlewidth

public function values ()

Return the values provided by the user. Test the CSRF before continue
NEVER read the values from $_POST in your codes or CSRF will not be
checked

public function verify ( $values, $fields=array ())

Check if the parameters are correct with the defined fields
Need the session !
@param array $values The values to check
@param array|null $fields The fields definition (or use the session
stored one if the value is null)
@return array containing the errors

Class \formfield

Namespace \

Description

The definition of a formfield

Properties

public $cols;

Number of columns

public $defaults;

The defaults values of the field

public $error;

The statut of error of the field

public $fieldwidth=10;

The Bootstrap width of the column of fields

public $formName;

The form name

public $group;

The name of group for the fields

public $help;

Allow a help message to be displayed below the field. In case of error,
it is overrided by the error message

public $hidden=false;

The state of the field : hidden or show

public $label;

The label of the field

public $mandatory;

The field is mandatory

public $multiple;

The multiplicity of selection of the field (available in select only)

public $name;

The name of the field

public $placeholder=false;

Display the placeholder if needed

public $readonly;

The read-only feature of the field

public $rows;

Number of rows

public $titles;

The titles of the field

public $titlewidth=2;

The Bootstrap width of the column of titles

public $type="text";

The type of the field (text, password, checkbox, select)

Methods

public function __construct ( $name, $label="")

When adding a field, the name and the label are the minimum mandatory
@param string $name Name of the field
@param string|null $label Label of the field

public function cols ( $val)

Set the cols
@param string $val The value of the cols

public function display ()

Display really the form

public function group ( $val)

Set the group
@param string $val The value of the group

public function help ( $val)

Set the help of the field
@param string $val The value of the help of the field

public function hidden ( $val)

Set the hidden of the field
@param string $val The value of the hidden of the field

public function mandatory ( $val)

Set the mandatory
@param string $val The value of the mandatory

public function multiple ( $val)

Set the multiple
@param string $val The value of the multiple

public function placeholder ( $val)

Set the placeholder
@param string $val The value of the placeholder

public function readonly ( $val)

Set the readonly
@param string $val The value of the readonly

public function rows ( $val)

Set the rows
@param string $val The value of the rows

public function type ( $val)

Set the type of the field
@param string $val The value of the type of the field