API page: http://api.drupal.org/api/drupal/includes--common.inc/function/drupal_pr...
This information is incomplete/incorrect:
The following states may be applied to an element:
enabled
disabled
visible
invisible
checked
unchecked
expanded
collapsedThe following states may be used in remote conditions:
enabled
disabled
visible
invisible
checked
unchecked
value
It should read:
The following states may be applied to an element:
enabled
disabled
required
optional
visible
invisible
checked
unchecked
expanded
collapsedThe following states may be used in remote conditions:
empty
filled
checked
unchecked
expanded
collapsed
value
For review: "states" are defined as events from line 342 onwards in misc/states.js and "remote conditions" are functions in states.Trigger.states from line 226.
Comment | File | Size | Author |
---|---|---|---|
#4 | drupal_process_states_documentation-1232722-4.patch | 1.19 KB | peterpoe |
#1 | drupal_process_states_documentation-1232722-1.patch | 1.04 KB | peterpoe |
Comments
Comment #1
peterpoe CreditAttribution: peterpoe commentedPatch here.
Comment #2
peterpoe CreditAttribution: peterpoe commentedComment #3
jhodgdonHm. Could someone please also fix this:
"states exist for both states and..."?!?!? I think it should be "states exist for both elements and..."?
Meanwhile, here is the file referenced above:
http://drupalcode.org/project/drupal.git/blob/HEAD:/misc/states.js
I'm seeing a list of state aliases at line 318, but other than that, how do we verify that this patch is correct -- I don't know a lot about states -- what are the element and remote states?
Comment #4
peterpoe CreditAttribution: peterpoe commentedAn example (from documentation) should make this clearer:
'visible' is the state that will be applied to the element when the "remote" element (input with name "remote_checkbox") satisfies a "checked == TRUE" condition. That is: the element will be visible only when the input checkbox with name "remote_checkbox" is checked.
The states that can be applied are found here:
http://drupalcode.org/project/drupal.git/blob/HEAD:/misc/states.js#l342
The remote conditions are these:
http://drupalcode.org/project/drupal.git/blob/HEAD:/misc/states.js#l226
Attached is updated patch with rewording suggested in #3.
Comment #5
jhodgdonI looked at the code you referenced, and I am not seeing how that matches your patch. For instance, the 2nd link seems to indicate to me that the states for remote are:
empty, checked, value, collapsed
but the list in your patch is quite a bit longer. What am I missing?
Comment #6
peterpoe CreditAttribution: peterpoe commentedAll state and conditions except value have a negative:
filled = !empty
unchecked = !checked
expanded = !collapsed
and so on...
Comment #7
jhodgdonOK. That seems reasonable... where is that defined?
And where is that list of "not fully implemented" things coming from?
Comment #8
peterpoe CreditAttribution: peterpoe commentedThey are defined in states.State.aliases:
http://drupalcode.org/project/drupal.git/blob/HEAD:/misc/states.js#l318
The "not fully implemented" states are simply those defined in states.State.aliases that have no corresponding state or condition. Don't ask me why they were left there :)
Comment #9
jhodgdonOK, I'm convinced. Thanks for helping me understand this. Looks like 7.x/8.x...
Comment #10
Dries CreditAttribution: Dries commentedCommitted to 7.x and 8.x.
Comment #11
andypostCould be a great follow-up #1091852: Display Bug when using #states (Forms API) with Ajax Request