FormHelper
class FormHelper (View source)
Provides helpers to operate on forms.
Methods
Rewrites #states selectors in a render element.
Helps recursively rewrite #states selectors.
Adds JavaScript to change the state of an element based on another element.
Details
static
rewriteStatesSelector(array $elements, string $search, string $replace)
Rewrites #states selectors in a render element.
When a structure of elements is being altered, their HTML selectors may change. In such cases calling this method will check if there are any states in element and its children, and rewrite selectors in those states.
static protected
processStatesArray(array $conditions, string $search, string $replace)
Helps recursively rewrite #states selectors.
Not to be confused with self::processStates(), which just prepares states for rendering.
static
processStates(array $elements)
Adds JavaScript to change the state of an element based on another element.
A "state" means a certain property of a DOM element, such as "visible" or "checked", which depends on a state or value of another element on the page. In general, states are HTML attributes and DOM element properties, which are applied initially, when page is loaded, depending on elements' default values, and then may change due to user interaction.
Since states are driven by JavaScript only, it is important to understand that all states are applied on presentation only, none of the states force any server-side logic, and that they will not be applied for site visitors without JavaScript support. All modules implementing states have to make sure that the intended logic also works without JavaScript being enabled.