I am using hook_inline_entity_form_entity_form_alter() and #ajax to load a set of values into a second select list based upon value from a first select list.
Let's say the first field is Team and the second field is Players to select from. The idea being that you can select a team, then select from it's roster of players. I followed the ajax dependent field example.
hook_inline_entity_form_entity_form_alter() works fine on the initial load, I can prepopulate the Team field with a list of values and add the #ajax item. But when the team is selected in the Team field and the #ajax callback is invoked, hook_inline_entity_form_entity_form_alter() doesn't get called again when the form-building function of the parent element is called.
Is this the way hook_inline_entity_form_entity_form_alter() and good ol' hook_form_alter() work or am I missing something? From what I understood, the modifications made to the form as a result of an ajax event are supposed to be made from within the form-building functions. Are the form altering hooks not called or is this an issue germane to IEF?
Structure would be:
Game
-> field_scoring (IEF)
Scoring
-> field_team
-> field_players
Thanks.
Comments
Comment #1
Train CreditAttribution: Train commentedComment #2
Train CreditAttribution: Train commentedSpelling...
Comment #3
Train CreditAttribution: Train commentedAnybody?
Comment #4
ron_s CreditAttribution: ron_s commentedForm alters are called as part of an
#ajax
event, but what might be a bit confusing is the order of processing. Form alters and validates occur before the ajax callback.Usually an
#after_build
is necessary to get the right results, since this is run after aform_alter
andform_validate
, and before the ajax callback.Comment #5
dcam CreditAttribution: dcam as a volunteer commentedClosing since there was no additional response.