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

markus_petrux’s picture

Category: bug » support
Status: Active » Fixed
asmdec’s picture

Status: Fixed » Needs review

My 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:

...
    // The following values were set by the content module and need
    // to be passed down to the nested element.
    '#title' => $element['#title'],
    '#required' => $element['#required'],
    '#description' => $element['#description'],
    '#field_name' => $element['#field_name'],
    '#type_name' => $element['#type_name'],
    '#delta' => $element['#delta'],
    '#columns' => $element['#columns'],
...

Why couldn't we set the '#disabled' attribute here too??

markus_petrux’s picture