This is because you convert a 'select' element into a 'value' element, but without changing the '#default_value' to '#value', here is a proper way to do it, patch attached.
| Comment | File | Size | Author |
|---|---|---|---|
| taxonomy_defaults.module-6.x-1.1-beta2-formapi_validation_error.patch | 614 bytes | pounard |
Comments
Comment #1
pounardYou can even remove the unset( .. ) line just under the last +'ed line.
Comment #2
bradweikel commentedpounard -- I'm no expert on Form API, so can you clarify how you know that it isn't validating? Your patch makes sense but I want to be sure I understand the issue.
Comment #3
pounardThis is a rather old isssue. If I remember well, this is something like this:
When you do this:
You pragmatically transform a 'select' type element into a value element. If you look deeper into the form API reference, you'll see that a 'value' element should have the '#value' property, not the '#default_value'.
Generally speaking, #value implies that the value can not be changed by the user, but #default_value assume that the user can change it. By definition, a 'value' element type can never be changed, so you need to set the '#value' property instead of the '#default_value' of the legacy 'select' element from the taxonomy form.
By creating a new element from scratch, I also remove some garbage that the form API won't use for the 'value' typ'ed elements, such as the '#options', and also do some cleaning (it might remove some validations functions as well, which you don't need because a 'value' element carries a fixed value which won't need any validation).
The side effect (on my box, can't remember the PHP version because I changed since) was a WSOD (PHP crash) an your module was unusable then.
Comment #4
bradweikel commented