I'm trying to disable a nodereference_select field in hook_form_alter with the code above but the field remains enabled.
$form['field_name']['#disabled'] = TRUE;
Debugging the code I found that in nodereference_select_process function '#disabled' attribute is not passed down to the nested element (same for the optionwidgets_select_process function in optionwidgets (sub)module).
Passing down the attribute will fix the issue.
Comments
Comment #1
markus_petrux commentedPlease, read this:
- Code snippet: How to set the disabled attribute of a CCK field
Comment #2
asmdec commentedMy question is: Why the FAPI process handler of the CCK field won't transfer the #disabled attribute to its children elements? It's not possible?
In nodereference_select_process function we have the following code and comment:
Why couldn't we set the '#disabled' attribute here too??
Comment #3
markus_petrux commented#336355: Unable to add '#attributes' or use '#disabled' = true via hook_form_alter()