Splitted from #942310: Field form cannot be attached more than once.

Problem: form_builder() doesn't allows to alter #limit_validation_errors for $form_state['triggering_element'] on #after_build. I think this is not how it must be. We can't always know where exactly submit button is on the form or parents array to validate.

Attached patch fixes the issue.

Comments

an.droid’s picture

Sorry, there are two files because I caught a 503 error when posting this issue.

sun.core’s picture

Category: bug » task

The stated problem is not a problem but a goal. Please state the problem.

effulgentsia’s picture

I'm also not clear on what the use-case problem is, but if we're unhappy that form_builder() does things after calling #after_build that modules are then unable to alter, how about if we move everything form_builder() does after calling #after_build into a #after_build callback of the 'file' and 'form' types?

an.droid’s picture

Well, the actual problem was in earlier work on patch for #942310: Field form cannot be attached more than once. Initially my suggestion was to use 'namespaces' to separate fields of different entities in $form_state['field']. This approach requires me to set #limit_validation_errors for 'add_more' buttons on #after_build when all parents are known. That's how I found this limitation.
As of now we moved from 'namespace' approach to use #parents instead, so the problem went away by itself.

I agree this is an edge case, so maybe we should postpone it until we find critical use-case problem?

quicksketch’s picture

Priority: Major » Normal
Status: Needs review » Closed (duplicate)

Seems like #942310: Field form cannot be attached more than once fixed this one? Obviously there hasn't been any more action on this since that issue was fixed, my guess is it fixed this issue too. In any case, this is at best a normal issue.