![]() ![]() The following states exist for both elements and remote conditions. The following states may be used when checking values of other fields: States that can be applied to a form field element: All modules implementing states have to make sure that the intended logic also works without JavaScript being enabled.Īdditionally, field actions that trigger a re-evaluation of state conditions assume user interaction if other javascript code programmatically updates the values or other properties of a targeted input, you may need to trigger a "user-like" action such as a keyup event. 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. ![]() In general, states depend on HTML attributes and DOM element properties, which change due to user interaction. A state can be applied to an element, depending on the state of another element on the page. The FormHelper::processStates() API docs state:Ī "state" means a certain property on a DOM element, such as "visible" or "checked". If a user selects "Other" you want to display a textfield where the user can enter their colour of choice. You won't list all colours on the planet so you add the option "Other" at the end of the list. Let's say you have a select field that let's users choose their favourite colour. While you could also use an AJAX Callback to achieve similar functionality the #states property allows creating dependent dynamic fields with little code. It does not matter whether that field is on the same form or not. When the value of the targeted field changes, the state of your element will change as well. You simply define an ordinary css selector of the target field in the #states property of your form field element.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |