Drupal 8  8.0.2
FormState Class Reference
Inheritance diagram for FormState:

Public Member Functions

 setFormState (array $form_state_additions)
 
 setAlwaysProcess ($always_process=TRUE)
 
 getAlwaysProcess ()
 
 setButtons (array $buttons)
 
 getButtons ()
 
 setCached ($cache=TRUE)
 
 isCached ()
 
 disableCache ()
 
 setExecuted ()
 
 isExecuted ()
 
 setGroups (array $groups)
 
getGroups ()
 
 setHasFileElement ($has_file_element=TRUE)
 
 hasFileElement ()
 
 setLimitValidationErrors ($limit_validation_errors)
 
 getLimitValidationErrors ()
 
 setMethod ($method)
 
 isMethodType ($method_type)
 
 setRequestMethod ($method)
 
 setValidationEnforced ($must_validate=TRUE)
 
 isValidationEnforced ()
 
 disableRedirect ($no_redirect=TRUE)
 
 isRedirectDisabled ()
 
 setProcessInput ($process_input=TRUE)
 
 isProcessingInput ()
 
 setProgrammed ($programmed=TRUE)
 
 isProgrammed ()
 
 setProgrammedBypassAccessCheck ($programmed_bypass_access_check=TRUE)
 
 isBypassingProgrammedAccessChecks ()
 
 setRebuildInfo (array $rebuild_info)
 
 getRebuildInfo ()
 
 addRebuildInfo ($property, $value)
 
 setStorage (array $storage)
 
getStorage ()
 
 setSubmitHandlers (array $submit_handlers)
 
 getSubmitHandlers ()
 
 setSubmitted ()
 
 isSubmitted ()
 
 setTemporary (array $temporary)
 
 getTemporary ()
 
getTemporaryValue ($key)
 
 setTemporaryValue ($key, $value)
 
 hasTemporaryValue ($key)
 
 setTriggeringElement ($triggering_element)
 
getTriggeringElement ()
 
 setValidateHandlers (array $validate_handlers)
 
 getValidateHandlers ()
 
 setValidationComplete ($validation_complete=TRUE)
 
 isValidationComplete ()
 
 loadInclude ($module, $type, $name=NULL)
 
 getCacheableArray ()
 
 setCompleteForm (array &$complete_form)
 
getCompleteForm ()
 
get ($property)
 
 set ($property, $value)
 
 has ($property)
 
 setBuildInfo (array $build_info)
 
 getBuildInfo ()
 
 addBuildInfo ($property, $value)
 
getUserInput ()
 
 setUserInput (array $user_input)
 
getValues ()
 
getValue ($key, $default=NULL)
 
 setValues (array $values)
 
 setValue ($key, $value)
 
 unsetValue ($key)
 
 hasValue ($key)
 
 isValueEmpty ($key)
 
 setValueForElement (array $element, $value)
 
 setResponse (Response $response)
 
 getResponse ()
 
 setRedirect ($route_name, array $route_parameters=array(), array $options=array())
 
 setRedirectUrl (Url $url)
 
 getRedirect ()
 
 setErrorByName ($name, $message= '')
 
 setError (array &$element, $message= '')
 
 clearErrors ()
 
 getError (array $element)
 
 getErrors ()
 
 setRebuild ($rebuild=TRUE)
 
 isRebuilding ()
 
 prepareCallback ($callback)
 
 setFormObject (FormInterface $form_object)
 
 getFormObject ()
 
 getCleanValueKeys ()
 
 setCleanValueKeys (array $cleanValueKeys)
 
 addCleanValueKey ($cleanValueKey)
 
 cleanValues ()
 
 setInvalidToken ($invalid_token)
 
 hasInvalidToken ()
 

Static Public Member Functions

static hasAnyErrors ()
 

Protected Member Functions

 isRequestMethodSafe ()
 
 moduleLoadInclude ($module, $type, $name=NULL)
 

Static Protected Member Functions

static setAnyErrors ($errors=TRUE)
 

Protected Attributes

 $complete_form
 
 $build_info
 
 $rebuild_info = array()
 
 $rebuild = FALSE
 
 $invalidToken = FALSE
 
 $response
 
 $redirect
 
 $no_redirect
 
 $method = 'POST'
 
 $requestMethod = 'GET'
 
 $cache = FALSE
 
 $no_cache
 
 $values = array()
 
 $cleanValueKeys
 
 $input
 
 $always_process
 
 $must_validate
 
 $programmed = FALSE
 
 $programmed_bypass_access_check = TRUE
 
 $process_input
 
 $submitted = FALSE
 
 $executed = FALSE
 
 $triggering_element
 
 $has_file_element
 
 $groups = array()
 
 $storage = array()
 
 $buttons = array()
 
 $temporary = []
 
 $validation_complete = FALSE
 
 $errors = array()
 
 $limit_validation_errors
 
 $validate_handlers = []
 
 $submit_handlers = []
 

Static Protected Attributes

static $anyErrors = FALSE
 

Detailed Description

Stores information about the state of a form.

Member Function Documentation

addBuildInfo (   $property,
  $value 
)

{Adds a value to the build info.

Parameters
string$propertyThe property to use for the value.
mixed$valueThe value to set.
Returns
$this
}

Implements FormStateInterface.

References FormState\getBuildInfo(), and FormState\setBuildInfo().

Referenced by FormState\setFormObject().

Here is the call graph for this function:

Here is the caller graph for this function:

addCleanValueKey (   $cleanValueKey)

{Adds a key to the array of form values that will be cleaned.

Parameters
string$keyThe form value key to be cleaned.
Returns
$this
}

Implements FormStateInterface.

References FormState\getCleanValueKeys(), and FormState\setCleanValueKeys().

Here is the call graph for this function:

addRebuildInfo (   $property,
  $value 
)

{Adds a value to the rebuild info.

Parameters
string$propertyThe property to use for the value.
mixed$valueThe value to set.
Returns
$this
}

Implements FormStateInterface.

References FormState\getRebuildInfo(), and FormState\setRebuildInfo().

Here is the call graph for this function:

cleanValues ( )

{Removes internal Form API elements and buttons from submitted form values.This function can be used when a module wants to store all submitted form values, for example, by serializing them into a single database column. In such cases, all internal Form API values and all form button elements should not be contained, and this function allows their removal before the module proceeds to storage. Next to button elements, the following internal values are removed by default.

  • form_id
  • form_token
  • form_build_id
  • op
Returns
$this
}

Implements FormStateInterface.

References FormState\getButtons(), FormState\getCleanValueKeys(), NestedArray\getValue(), FormState\getValues(), and FormState\unsetValue().

Here is the call graph for this function:

clearErrors ( )

{Clears all errors against all form elements made by self::setErrorByName().}

Implements FormStateInterface.

disableCache ( )

{Prevents the form from being cached.

Returns
$this
}

Implements FormStateInterface.

disableRedirect (   $no_redirect = TRUE)

{Prevents the form from redirecting.

Parameters
bool$no_redirectIf TRUE, the form will not redirect.
Returns
$this
}

Implements FormStateInterface.

& get (   $property)

{Gets any arbitrary property.

Parameters
string | array$propertyProperties are often stored as multi-dimensional associative arrays. If $property is a string, it will return $storage[$property]. If $property is an array, each element of the array will be used as a nested key. If $property = ['foo', 'bar'] it will return $storage['foo']['bar'].
Returns
mixed A reference to the value for that property, or NULL if the property does not exist.
}

Implements FormStateInterface.

References NestedArray\getValue().

Here is the call graph for this function:

getAlwaysProcess ( )

{Determines if this form should always be processed.

Returns
bool TRUE if the form should always be processed, FALSE otherwise.
}

Implements FormStateInterface.

getBuildInfo ( )

{Returns the build info for the form.

Returns
array An array of build info.
See Also
::$build_info
}

Implements FormStateInterface.

Referenced by FormState\addBuildInfo(), FormState\getCacheableArray(), FormState\getFormObject(), and FormState\loadInclude().

Here is the caller graph for this function:

getButtons ( )

{Returns the submit and button elements for the form.

Returns
array The submit and button elements.
}

Implements FormStateInterface.

Referenced by FormState\cleanValues().

Here is the caller graph for this function:

getCacheableArray ( )

{Returns an array representation of the cacheable portion of the form state.

Returns
array The cacheable portion of the form state.
}

Implements FormStateInterface.

References FormState\getBuildInfo(), FormState\getResponse(), FormState\getStorage(), FormState\hasFileElement(), FormState\isBypassingProgrammedAccessChecks(), FormState\isProcessingInput(), and FormState\isProgrammed().

Here is the call graph for this function:

getCleanValueKeys ( )

{Gets the keys of the form values that will be cleaned.

Returns
array An array of form value keys to be cleaned.
}

Implements FormStateInterface.

Referenced by FormState\addCleanValueKey(), and FormState\cleanValues().

Here is the caller graph for this function:

& getCompleteForm ( )

{Returns a reference to the complete form array.

Returns
array The complete form array.
}

Implements FormStateInterface.

getError ( array  $element)

{Returns the error message filed against the given form element.Form errors higher up in the form structure override deeper errors as well as errors on the element itself.

Parameters
array$elementThe form element to check for errors.
Returns
string|null Either the error message for this element or NULL if there are no errors.
}

Implements FormStateInterface.

References FormState\getErrors().

Here is the call graph for this function:

getErrors ( )

{Returns an associative array of all errors.

Returns
array An array of all errors, keyed by the name of the form element.
}

Implements FormStateInterface.

Referenced by FormState\getError(), and FormState\setErrorByName().

Here is the caller graph for this function:

getFormObject ( )

{Returns the form object that is responsible for building this form.

Returns
The form object.
}

Implements FormStateInterface.

References FormState\getBuildInfo().

Referenced by FormState\prepareCallback().

Here is the call graph for this function:

Here is the caller graph for this function:

& getGroups ( )

{Returns references to details elements to render them within vertical tabs.

Returns
array
}

Implements FormStateInterface.

getLimitValidationErrors ( )

{Retrieves the limited validation error sections.

Returns
array|null The limited validation error sections.
See Also
::$limit_validation_errors
}

Implements FormStateInterface.

Referenced by FormState\setErrorByName().

Here is the caller graph for this function:

getRebuildInfo ( )

{Gets the rebuild info.

Returns
array The rebuild info.
See Also
::$rebuild_info
}

Implements FormStateInterface.

Referenced by FormState\addRebuildInfo().

Here is the caller graph for this function:

getRedirect ( )

{Gets the value to use for redirecting after the form has been executed.

See Also
::redirectForm()
Returns
mixed The value will be one of the following:
  • A fully prepared .
  • An instance of to use for the redirect.
  • NULL, to signify that no redirect was specified and that the current path should be used for the redirect.
  • FALSE, to signify that no redirect should take place.
}

Implements FormStateInterface.

References FormState\isProgrammed(), FormState\isRebuilding(), and FormState\isRedirectDisabled().

Here is the call graph for this function:

getResponse ( )

{Gets a response for this form.If a response is set, it will be used during processing and returned directly. The form will not be rebuilt or redirected.

Returns
|null The response to return, or NULL.
}

Implements FormStateInterface.

Referenced by FormState\getCacheableArray().

Here is the caller graph for this function:

& getStorage ( )

{Returns the entire set of arbitrary data.

Returns
array The entire set of arbitrary data to store for this form.
}

Implements FormStateInterface.

Referenced by FormState\getCacheableArray().

Here is the caller graph for this function:

getSubmitHandlers ( )

{Gets the submit handlers.

Returns
array An array of submit handlers.
}

Implements FormStateInterface.

getTemporary ( )

{Gets temporary data.

Returns
array Temporary data accessible during the current page request only.
}

Implements FormStateInterface.

& getTemporaryValue (   $key)

{Gets an arbitrary value from temporary storage.

Parameters
string | array$keyProperties are often stored as multi-dimensional associative arrays. If $key is a string, it will return $temporary[$key]. If $key is an array, each element of the array will be used as a nested key. If $key = ['foo', 'bar'] it will return $temporary['foo']['bar'].
Returns
mixed A reference to the value for that key, or NULL if the property does not exist.
}

Implements FormStateInterface.

References NestedArray\getValue().

Here is the call graph for this function:

& getTriggeringElement ( )

{Gets the form element that triggered submission.

Returns
array|null The form element that triggered submission, of NULL if there is none.
}

Implements FormStateInterface.

& getUserInput ( )

{Returns the form values as they were submitted by the user.These are raw and unvalidated, so should not be used without a thorough understanding of security implications. In almost all cases, code should use self::getValues() and self::getValue() exclusively.

Returns
array An associative array of values submitted to the form.
}

Implements FormStateInterface.

getValidateHandlers ( )

{Gets the validate handlers.

Returns
array An array of validate handlers.
}

Implements FormStateInterface.

& getValue (   $key,
  $default = NULL 
)

{Returns the submitted form value for a specific key.

Parameters
string | array$keyValues are stored as a multi-dimensional associative array. If $key is a string, it will return $values[$key]. If $key is an array, each element of the array will be used as a nested key. If $key = array('foo', 'bar') it will return $values['foo']['bar'].
mixed$default(optional) The default value if the specified key does not exist.
Returns
mixed The value for the given key, or NULL.
}

Implements FormStateInterface.

References NestedArray\getValue(), and FormState\getValues().

Here is the call graph for this function:

& getValues ( )

{Returns the submitted and sanitized form values.

Returns
array An associative array of values submitted to the form.
}

Implements FormStateInterface.

Referenced by FormState\cleanValues(), FormState\getValue(), FormState\hasValue(), FormState\isValueEmpty(), FormState\setValue(), and FormState\unsetValue().

Here is the caller graph for this function:

has (   $property)

{Determines if an arbitrary property is present.

Parameters
string$propertyProperties are often stored as multi-dimensional associative arrays. If $property is a string, it will return isset($storage[$property]). If $property is an array, each element of the array will be used as a nested key. If $property = ['foo', 'bar'] it will return isset($storage['foo']['bar']).
}

Implements FormStateInterface.

References NestedArray\getValue().

Here is the call graph for this function:

static hasAnyErrors ( )
static

{Determines if any forms have any errors.

Returns
bool TRUE if any form has any errors, FALSE otherwise.
}

Implements FormStateInterface.

Referenced by ViewExecutable\build(), and FormBuilder\processForm().

Here is the caller graph for this function:

hasFileElement ( )

{Returns whether this form has a file element.

Returns
bool Whether this form has a file element.
}

Implements FormStateInterface.

Referenced by FormState\getCacheableArray().

Here is the caller graph for this function:

hasInvalidToken ( )

{Determines if the form has an invalid token.

Returns
bool TRUE if the form has an invalid token, FALSE otherwise.
}

Implements FormStateInterface.

hasTemporaryValue (   $key)

{Determines if a temporary value is present.

Parameters
string$keyProperties are often stored as multi-dimensional associative arrays. If $key is a string, it will return isset($temporary[$key]). If $key is an array, each element of the array will be used as a nested key. If $key = ['foo', 'bar'] it will return isset($temporary['foo']['bar']).
}

Implements FormStateInterface.

References NestedArray\getValue().

Here is the call graph for this function:

hasValue (   $key)

{Determines if a specific key is present in the submitted form values.

Parameters
string | array$keyValues are stored as a multi-dimensional associative array. If $key is a string, it will return isset($values[$key]). If $key is an array, each element of the array will be used as a nested key. If $key = array('foo', 'bar') it will return isset($values['foo']['bar']).
Returns
bool TRUE if the $key is set, FALSE otherwise.
}

Implements FormStateInterface.

References NestedArray\getValue(), and FormState\getValues().

Here is the call graph for this function:

isBypassingProgrammedAccessChecks ( )

{Determines if this form submission should bypass #access.

Returns
bool
See Also
::$programmed_bypass_access_check
}

Implements FormStateInterface.

Referenced by FormState\getCacheableArray().

Here is the caller graph for this function:

isCached ( )

{Determines if the form should be cached.

Returns
bool TRUE if the form should be cached, FALSE otherwise.
}

Implements FormStateInterface.

isExecuted ( )

{Determines if the form was submitted and has been processed and executed.

Returns
bool TRUE if the form was submitted and has been processed and executed.
}

Implements FormStateInterface.

isMethodType (   $method_type)

{Returns the HTTP form method.

Parameters
stringThe HTTP form method.
Returns
bool TRUE if the HTTP form method matches.
See Also
::$method
}

Implements FormStateInterface.

isProcessingInput ( )

{Determines if the form input will be processed.

Returns
bool If TRUE, the form input will be processed.
}

Implements FormStateInterface.

Referenced by FormState\getCacheableArray().

Here is the caller graph for this function:

isProgrammed ( )

{Returns if this form was submitted programmatically.

Returns
bool If TRUE, the form was submitted programmatically.
}

Implements FormStateInterface.

Referenced by FormState\getCacheableArray(), and FormState\getRedirect().

Here is the caller graph for this function:

isRebuilding ( )

{Determines if the form should be rebuilt after processing.

Returns
bool TRUE if the form should be rebuilt, FALSE otherwise.
}

Implements FormStateInterface.

Referenced by FormState\getRedirect().

Here is the caller graph for this function:

isRedirectDisabled ( )

{Determines if redirecting has been prevented.

Returns
bool If TRUE, the form will not redirect.
}

Implements FormStateInterface.

Referenced by FormState\getRedirect().

Here is the caller graph for this function:

isRequestMethodSafe ( )
protected

Checks whether the request method is a "safe" HTTP method.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.1.1 defines GET and HEAD as "safe" methods, meaning they SHOULD NOT have side-effects, such as persisting $form_state changes.

Returns
bool
See Also
::isMethodSafe()

Referenced by FormState\setCached().

Here is the caller graph for this function:

isSubmitted ( )

{Determines if the form has been submitted.

Returns
bool TRUE if the form has been submitted, FALSE otherwise.
}

Implements FormStateInterface.

isValidationComplete ( )

{Determines if validation has been completed.

Returns
bool TRUE if validation is complete, FALSE otherwise.
}

Implements FormStateInterface.

Referenced by FormState\setErrorByName().

Here is the caller graph for this function:

isValidationEnforced ( )

{Checks if validation is enforced.

Returns
bool If TRUE, validation will always be run.
}

Implements FormStateInterface.

isValueEmpty (   $key)

{Determines if a specific key has a value in the submitted form values.

Parameters
string | array$keyValues are stored as a multi-dimensional associative array. If $key is a string, it will return empty($values[$key]). If $key is an array, each element of the array will be used as a nested key. If $key = array('foo', 'bar') it will return empty($values['foo']['bar']).
Returns
bool TRUE if the $key has no value, FALSE otherwise.
}

Implements FormStateInterface.

References NestedArray\getValue(), and FormState\getValues().

Here is the call graph for this function:

loadInclude (   $module,
  $type,
  $name = NULL 
)

{Ensures an include file is loaded whenever the form is processed.Example:

// Load node.admin.inc from Node module.
$form_state->loadInclude('node', 'inc', 'node.admin');
Use this function instead of module_load_include() from inside a form constructor or any form processing logic as it ensures that the include file is loaded whenever the form is processed. In contrast to using module_load_include() directly, this method makes sure the include file is correctly loaded also if the form is cached.
Parameters
string$moduleThe module to which the include file belongs.
string$typeThe include file's type (file extension).
string | null$name(optional) The base file name (without the $type extension). If omitted, $module is used; i.e., resulting in "$module.$type" by default.
Returns
string|false The filepath of the loaded include file, or FALSE if the include file was not found or has been loaded already.
See Also
module_load_include()
}

Implements FormStateInterface.

References FormState\getBuildInfo(), FormState\moduleLoadInclude(), and FormState\setBuildInfo().

Here is the call graph for this function:

moduleLoadInclude (   $module,
  $type,
  $name = NULL 
)
protected

Wraps ModuleHandler::loadInclude().

Referenced by FormState\loadInclude().

Here is the caller graph for this function:

prepareCallback (   $callback)

{Converts support notations for a form callback to a valid callable.Specifically, supports methods on the form/callback object as strings when they start with ::, for example "::submitForm()".

Parameters
string | array$callbackThe callback.
Returns
array|string A valid callable.
}

Implements FormStateInterface.

References FormState\getFormObject().

Here is the call graph for this function:

set (   $property,
  $value 
)

{Sets a value to an arbitrary property.

Parameters
string | array$propertyProperties are often stored as multi-dimensional associative arrays. If $property is a string, it will use $storage[$property] = $value. If $property is an array, each element of the array will be used as a nested key. If $property = ['foo', 'bar'] it will use $storage['foo']['bar'] = $value.
mixed$valueThe value to set.
Returns
$this
}

Implements FormStateInterface.

References NestedArray\setValue().

Referenced by FormState\setFormState().

Here is the call graph for this function:

Here is the caller graph for this function:

setAlwaysProcess (   $always_process = TRUE)

{Sets this form to always be processed.This should only be used on RESTful GET forms that do NOT write data, as this could lead to security issues. It is useful so that searches do not need to have a form_id in their query arguments to trigger the search.

Parameters
bool$always_processTRUE if the form should always be processed, FALSE otherwise.
Returns
$this
}

Implements FormStateInterface.

static setAnyErrors (   $errors = TRUE)
staticprotected

Sets the global status of errors.

Parameters
bool$errorsTRUE if any form has any errors, FALSE otherwise.
setBuildInfo ( array  $build_info)

{Sets the build info for the form.

Parameters
array$build_infoAn array of build info.
Returns
$this
See Also
::$build_info
}

Implements FormStateInterface.

Referenced by FormState\addBuildInfo(), and FormState\loadInclude().

Here is the caller graph for this function:

setButtons ( array  $buttons)

{Stores the submit and button elements for the form.

Parameters
array$buttonsThe submit and button elements.
Returns
$this
}

Implements FormStateInterface.

setCached (   $cache = TRUE)

{Sets this form to be cached.

Parameters
bool$cacheTRUE if the form should be cached, FALSE otherwise.
Returns
$this
Exceptions
\LogicExceptionIf the current request is using an HTTP method that must not change state (e.g., GET).
}

Implements FormStateInterface.

References Drupal\cache(), and FormState\isRequestMethodSafe().

Here is the call graph for this function:

setCleanValueKeys ( array  $cleanValueKeys)

{Sets the keys of the form values that will be cleaned.

Parameters
array$keysAn array of form value keys to be cleaned.
Returns
$this
}

Implements FormStateInterface.

Referenced by FormState\addCleanValueKey().

Here is the caller graph for this function:

setCompleteForm ( array &  $complete_form)

{Stores the complete form array.

Parameters
array$complete_formThe complete form array.
Returns
$this
}

Implements FormStateInterface.

setError ( array &  $element,
  $message = '' 
)

{Flags an element as having an error.

Parameters
array$elementThe form element.
string$message(optional) The error message to present to the user.
Returns
$this
}

Implements FormStateInterface.

References FormState\setErrorByName().

Here is the call graph for this function:

setErrorByName (   $name,
  $message = '' 
)

{Files an error against a form element.When a validation error is detected, the validator calls this method to indicate which element needs to be changed and provide an error message. This causes the Form API to not execute the form submit handlers, and instead to re-display the form to the user with the corresponding elements rendered with an 'error' CSS class (shown as red by default).The standard behavior of this method can be changed if a button provides the #limit_validation_errors property. Multistep forms not wanting to validate the whole form can set #limit_validation_errors on buttons to limit validation errors to only certain elements. For example, pressing the "Previous" button in a multistep form should not fire validation errors just because the current step has invalid values. If #limit_validation_errors is set on a clicked button, the button must also define a #submit property (may be set to an empty array). Any #submit handlers will be executed even if there is invalid input, so extreme care should be taken with respect to any actions taken by them. This is typically not a problem with buttons like "Previous" or "Add more" that do not invoke persistent storage of the submitted form values. Do not use the #limit_validation_errors property on buttons that trigger saving of form values to the database.The #limit_validation_errors property is a list of "sections" within $form_state->getValues() that must contain valid values. Each "section" is an array with the ordered set of keys needed to reach that part of $form_state->getValues() (i.e., the #parents property of the element).Example 1: Allow the "Previous" button to function, regardless of whether any user input is valid.

$form['actions']['previous'] = array(
'#type' => 'submit',
'#value' => t('Previous'),
'#limit_validation_errors' => array(), // No validation.
'#submit' => array('some_submit_function'), // #submit required.
);
Example 2: Require some, but not all, user input to be valid to process the submission of a "Previous" button.
$form['actions']['previous'] = array(
'#type' => 'submit',
'#value' => t('Previous'),
'#limit_validation_errors' => array(
// Validate $form_state->getValue('step1').
array('step1'),
// Validate $form_state->getValue(array('foo', 'bar')).
array('foo', 'bar'),
),
'#submit' => array('some_submit_function'), // #submit required.
);
This will require $form_state->getValue('step1') and everything within it (for example, $form_state->getValue(array('step1', 'choice'))) to be valid, so calls to self::setErrorByName('step1', $message) or self::setErrorByName('step1][choice', $message) will prevent the submit handlers from running, and result in the error message being displayed to the user. However, calls to self::setErrorByName('step2', $message) and self::setErrorByName('step2][groupX][choiceY', $message) will be suppressed, resulting in the message not being displayed to the user, and the submit handlers will run despite $form_state->getValue('step2') and $form_state->getValue(array('step2', 'groupX', 'choiceY')) containing invalid values. Errors for an invalid $form_state->getValue('foo') will be suppressed, but errors flagging invalid values for $form_state->getValue(array('foo', 'bar')) and everything within it will be flagged and submission prevented.Partial form validation is implemented by suppressing errors rather than by skipping the input processing and validation steps entirely, because some forms have button-level submit handlers that call Drupal API functions that assume that certain data exists within $form_state->getValues(), and while not doing anything with that data that requires it to be valid, PHP errors would be triggered if the input processing and validation steps were fully skipped.
Parameters
string$nameThe name of the form element. If the #parents property of your form element is array('foo', 'bar', 'baz') then you may set an error on 'foo' or 'foo][bar][baz'. Setting an error on 'foo' sets an error for every element where the #parents array starts with 'foo'.
string$message(optional) The error message to present to the user.
Returns
$this
}

Implements FormStateInterface.

References FormState\getErrors(), FormState\getLimitValidationErrors(), and FormState\isValidationComplete().

Referenced by FormState\setError().

Here is the call graph for this function:

Here is the caller graph for this function:

setExecuted ( )

{Sets that the form was submitted and has been processed and executed.

Returns
$this
}

Implements FormStateInterface.

setFormObject ( FormInterface  $form_object)

{Sets the form object that is responsible for building this form.

Parameters
\Drupal\Core\Form\FormInterface$form_objectThe form object.
Returns
$this
}

Implements FormStateInterface.

References FormState\addBuildInfo().

Here is the call graph for this function:

setFormState ( array  $form_state_additions)

{Sets the value of the form state.

Parameters
array$form_state_additionsAn array of values to add to the form state.
Returns
$this
}

Implements FormStateInterface.

References FormState\set().

Here is the call graph for this function:

setGroups ( array  $groups)

{Sets references to details elements to render them within vertical tabs.

Parameters
array$groupsReferences to details elements to render them within vertical tabs.
Returns
$this
}

Implements FormStateInterface.

setHasFileElement (   $has_file_element = TRUE)

{Sets that this form has a file element.

Parameters
bool$has_file_elementWhether this form has a file element.
Returns
$this
}

Implements FormStateInterface.

setInvalidToken (   $invalid_token)

{Flags the form state as having or not an invalid token.

Parameters
bool$invalid_tokenWhether the form has an invalid token.
Returns
$this
}

Implements FormStateInterface.

setLimitValidationErrors (   $limit_validation_errors)

{Sets the limited validation error sections.

Parameters
array | null$limit_validation_errorsThe limited validation error sections.
Returns
$this
See Also
::$limit_validation_errors
}

Implements FormStateInterface.

setMethod (   $method)

{Sets the HTTP method to use for the form's submission.This is what the form's "method" attribute should be, not necessarily what the current request's HTTP method is. For example, a form can have a method attribute of POST, but the request that initially builds it uses GET.

Parameters
string$methodEither "GET" or "POST". Other HTTP methods are not valid form submission methods.
See Also
::$method
::setRequestMethod()
Returns
$this
}

Implements FormStateInterface.

setProcessInput (   $process_input = TRUE)

{Sets that the form should process input.

Parameters
bool$process_inputIf TRUE, the form input will be processed.
Returns
$this
}

Implements FormStateInterface.

setProgrammed (   $programmed = TRUE)

{Sets that this form was submitted programmatically.

Parameters
bool$programmedIf TRUE, the form was submitted programmatically.
Returns
$this
}

Implements FormStateInterface.

setProgrammedBypassAccessCheck (   $programmed_bypass_access_check = TRUE)

{Sets if this form submission should bypass #access.

Parameters
bool$programmed_bypass_access_checkIf TRUE, programmatic form submissions are processed without taking #access into account.
Returns
$this
See Also
::$programmed_bypass_access_check
}

Implements FormStateInterface.

setRebuild (   $rebuild = TRUE)

{Sets the form to be rebuilt after processing.

Parameters
bool$rebuild(optional) Whether the form should be rebuilt or not. Defaults to TRUE.
Returns
$this
}

Implements FormStateInterface.

setRebuildInfo ( array  $rebuild_info)

{Sets the rebuild info.

Parameters
array$rebuild_infoThe rebuild info.
Returns
$this
See Also
::$rebuild_info
}

Implements FormStateInterface.

Referenced by FormState\addRebuildInfo().

Here is the caller graph for this function:

setRedirect (   $route_name,
array  $route_parameters = array(),
array  $options = array() 
)

{Sets the redirect for the form.

Parameters
string$route_nameThe name of the route
array$route_parameters(optional) An associative array of parameter names and values.
array$options(optional) An associative array of additional options. See for the available keys.
Returns
$this
See Also
::redirectForm()
}

Implements FormStateInterface.

References FormState\setRedirectUrl().

Here is the call graph for this function:

setRedirectUrl ( Url  $url)

{Sets the redirect URL for the form.

Parameters
\Drupal\Core\Url$urlThe URL to redirect to.
Returns
$this
See Also
::redirectForm()
}

Implements FormStateInterface.

Referenced by FormState\setRedirect().

Here is the caller graph for this function:

setRequestMethod (   $method)

{Sets the HTTP method used by the request that is building the form.

Parameters
string$methodCan be any valid HTTP method, such as GET, POST, HEAD, etc.
Returns
$this
See Also
::setMethod()
}

Implements FormStateInterface.

setResponse ( Response  $response)

{Sets a response for this form.If a response is set, it will be used during processing and returned directly. The form will not be rebuilt or redirected.

Parameters
\Symfony\Component\HttpFoundation\Response$responseThe response to return.
Returns
$this
}

Implements FormStateInterface.

setStorage ( array  $storage)

{Sets the entire set of arbitrary data.

Parameters
array$storageThe entire set of arbitrary data to store for this form.
Returns
$this
}

Implements FormStateInterface.

setSubmitHandlers ( array  $submit_handlers)

{Sets the submit handlers.

Parameters
array$submit_handlersAn array of submit handlers.
Returns
$this
}

Implements FormStateInterface.

setSubmitted ( )

{Sets that the form has been submitted.

Returns
$this
}

Implements FormStateInterface.

setTemporary ( array  $temporary)

{Sets temporary data.

Parameters
array$temporaryTemporary data accessible during the current page request only.
Returns
$this
}

Implements FormStateInterface.

setTemporaryValue (   $key,
  $value 
)

{Sets an arbitrary value in temporary storage.

Parameters
string | array$keyProperties are often stored as multi-dimensional associative arrays. If $key is a string, it will use $temporary[$key] = $value. If $key is an array, each element of the array will be used as a nested key. If $key = ['foo', 'bar'] it will use $temporary['foo']['bar'] = $value.
mixed$valueThe value to set.
Returns
$this
}

Implements FormStateInterface.

References NestedArray\setValue().

Here is the call graph for this function:

setTriggeringElement (   $triggering_element)

{Sets the form element that triggered submission.

Parameters
array | null$triggering_elementThe form element that triggered submission, of NULL if there is none.
Returns
$this
}

Implements FormStateInterface.

setUserInput ( array  $user_input)

{Sets the form values as though they were submitted by a user.

Parameters
array$user_inputAn associative array of raw and unvalidated values.
Returns
$this
}

Implements FormStateInterface.

setValidateHandlers ( array  $validate_handlers)

{Sets the validate handlers.

Parameters
array$validate_handlersAn array of validate handlers.
Returns
$this
}

Implements FormStateInterface.

setValidationComplete (   $validation_complete = TRUE)

{Sets that validation has been completed.

Parameters
bool$validation_completeTRUE if validation is complete, FALSE otherwise.
Returns
$this
}

Implements FormStateInterface.

setValidationEnforced (   $must_validate = TRUE)

{Enforces that validation is run.

Parameters
bool$must_validateIf TRUE, validation will always be run.
Returns
$this
}

Implements FormStateInterface.

setValue (   $key,
  $value 
)

{Sets the submitted form value for a specific key.

Parameters
string | array$keyValues are stored as a multi-dimensional associative array. If $key is a string, it will use $values[$key] = $value. If $key is an array, each element of the array will be used as a nested key. If $key = array('foo', 'bar') it will use $values['foo']['bar'] = $value.
mixed$valueThe value to set.
Returns
$this
}

Implements FormStateInterface.

References FormState\getValues(), and NestedArray\setValue().

Referenced by FormState\setValueForElement().

Here is the call graph for this function:

Here is the caller graph for this function:

setValueForElement ( array  $element,
  $value 
)

{Changes submitted form values during form validation.Use this function to change the submitted value of a form element in a form validation function, so that the changed value persists in $form_state through to the submission handlers.Note that form validation functions are specified in the '#validate' component of the form array (the value of $form['#validate'] is an array of validation function names). If the form does not originate in your module, you can implement hook_form_FORM_ID_alter() to add a validation function to $form['#validate'].

Parameters
array$elementThe form element that should have its value updated; in most cases you can just pass in the element from the $form array, although the only component that is actually used is '#parents'. If constructing yourself, set $element['#parents'] to be an array giving the path through the form array's keys to the element whose value you want to update. For instance, if you want to update the value of $form['elem1']['elem2'], which should be stored in $form_state->getValue(array('elem1', 'elem2')), you would set $element['#parents'] = array('elem1','elem2').
mixed$valueThe new value for the form element.
Returns
$this
}

Implements FormStateInterface.

References FormState\setValue().

Here is the call graph for this function:

setValues ( array  $values)

{Sets the submitted form values.This should be avoided, since these values have been validated already. Use self::setUserInput() instead.

Parameters
array$valuesThe multi-dimensional associative array of form values.
Returns
$this
}

Implements FormStateInterface.

unsetValue (   $key)

{Removes a specific key from the submitted form values.

Parameters
string | array$keyValues are stored as a multi-dimensional associative array. If $key is a string, it will use unset($values[$key]). If $key is an array, each element of the array will be used as a nested key. If $key = array('foo', 'bar') it will use unset($values['foo']['bar']).
Returns
$this
}

Implements FormStateInterface.

References FormState\getValues(), and NestedArray\unsetValue().

Referenced by FormState\cleanValues().

Here is the call graph for this function:

Here is the caller graph for this function:

Field Documentation

$build_info
protected
Initial value:
= array(
'args' => array(),
'files' => array(),
)
$cleanValueKeys
protected
Initial value:
= [
'form_id',
'form_token',
'form_build_id',
'op',
]

The documentation for this class was generated from the following file: