- Class name: Form
- Namespace: JSMF
String JSMF\Form::__toString()
outputs all the form fields (but not the
tags!!)- Visibility: public
String JSMF\Form::__get(String $fieldName)
returns the HTML for a form field
- Visibility: public
- $fieldName String
String JSMF\Form::__call($fieldName, array $attributes)
returns the HTML for a form field and sets the given field attributes
- Visibility: public
- $fieldName mixed
- $attributes array
mixed JSMF\Form::__construct(String|null $formName, Boolean|false $enableCsrfCheck, String|null $csrfFailMessage)
creates new form
- Visibility: public
- $formName String|null - <p>(unique name of this form, needed for csrf check. Must be fixed name, no random uniqueid)</p>
- $enableCsrfCheck Boolean|false
- $csrfFailMessage String|null
\JSMF\Form JSMF\Form::printLabelAfterElement(Boolean|true $val)
sets the option to print the label AFTER the element (useful for css only matierial design)
- Visibility: public
- $val Boolean|true
Array JSMF\Form::getData(Boolean|false $ignoreValidation)
returns the form data
- Visibility: public
- $ignoreValidation Boolean|false - <p>(set to true to get data without calling validate() method before, otherwise exception is thrown)</p>
Boolean JSMF\Form::validate(Array $messages, \JSMF\bool $csrfFailed)
validates the form
- Visibility: public
- $messages Array - <p>(if form is invalid, the failing messages where added to this array)</p>
- $csrfFailed JSMF\bool
\JSMF\Form JSMF\Form::addValidator(String $validatorClass, String $invalidMessageTranslationKey, \JSMF\Arary $arguments)
add a validator to the last added field
- Visibility: public
- $validatorClass String
- $invalidMessageTranslationKey String
- $arguments JSMF\Arary
\JSMF\Form JSMF\Form::setFieldWrapper(String $tag, Array $classes)
set an element to wrap each label/field occurence
- Visibility: public
- $tag String - <p>(the HTML Tag without <>)</p>
- $classes Array - <p>(optional classes to add to wrapper)</p>
\JSMF\Form JSMF\Form::addField(String $name, String|null $label, String|null $id, String|\JSMF\text $type, Array|null $values, Mixed|null $defaultValue)
adds a new field to the form setup
- Visibility: public
- $name String
- $label String|null
- $id String|null - <p>(if not given, is set to $name)</p>
- $type String|JSMF\text - <p>(for the different field types (e.g. select, checkbox...) - you can also use the shortcut functions e.g. addSelect, addCheckbox...)</p>
- $values Array|null - <p>(if fieldType needs values / options (e.g. selectboxes etc.))</p>
- $defaultValue Mixed|null
\JSMF\Form JSMF\Form::addSelect(String $name, Array $options, String|null $label, String|null $id, Mixed|null $defaultValue)
adds a selectbox field
- Visibility: public
- $name String
- $options Array - <p>(key=radiobutton value, value=radiobutton label)</p>
- $label String|null
- $id String|null - <p>(if not given, is set to $name)</p>
- $defaultValue Mixed|null
\JSMF\Form JSMF\Form::addCheckbox(String $name, String $onValue, String|null $label, String|null $id, Mixed|null $defaultValue)
adds a checbox
- Visibility: public
- $name String
- $onValue String
- $label String|null
- $id String|null - <p>(if not given, is set to $name)</p>
- $defaultValue Mixed|null
\JSMF\Form JSMF\Form::addRadiobutton(String $name, Array $options, String|null $label, String|null $id, Mixed|null $defaultValue)
adds a radiobutton group
- Visibility: public
- $name String
- $options Array - <p>(key=radiobutton value, value=radiobutton label)</p>
- $label String|null
- $id String|null - <p>(if not given, is set to $name)</p>
- $defaultValue Mixed|null
\JSMF\Form JSMF\Form::addTextarea(String $name, String|null $label, String|null $id, Mixed|null $defaultValue)
adds a textarea field
- Visibility: public
- $name String
- $label String|null
- $id String|null - <p>(if not given, is set to $name)</p>
- $defaultValue Mixed|null
\JSMF\Form JSMF\Form::setOutputLabel(Boolean $option)
sets label outputting on or off (default is on)
- Visibility: public
- $option Boolean - <p>(true to output label, false to do not)</p>
Boolean JSMF\Form::isSubmitted()
return if this form was submitted
- Visibility: public
Void JSMF\Form::reset()
resets the form
- Visibility: public
Void JSMF\Form::setValue(String $field, Mixed $value)
sets a fields value
- Visibility: public
- $field String
- $value Mixed
string JSMF\Form::regenerateCsrfToken()
Regenerates CSRF Token and returns the new token
- Visibility: public
string JSMF\Form::getFormName()
Returns current form name
- Visibility: public
mixed JSMF\Form::overrideCSRFToken(string $token)
Overrides crsf token. should be used with caution!
- Visibility: public
- $token string