To reproduce:

  1. Create term reference field with any select (or other) widget
  2. In a module implement hook_form_alter and set $form[field_name]['#disabled'] = TRUE;
  3. When viewing the form, one can still interact with the widget, even though examining the $form array, the field has our defined #disabled element.
CommentFileSizeAuthor
#4 fapi_disabled_state-2407567-4.patch1.77 KBlegolasbo
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

legolasbo’s picture

Status: Active » Closed (cannot reproduce)

I'm unable to reproduce this on the latest 7.x-3.x-dev.

gbyte’s picture

Status: Closed (cannot reproduce) » Active

I just grabbed a fresh instance of Drupal 7.32 and reproduced the issue (as described above) on the latest dev as well.

Found out however that when using
$form[field_name]['und']['#disabled'] = TRUE;

instead of
$form[field_name]['#disabled'] = TRUE;

the field gets disabled correctly.

That seems inconsequent as disabling regular select list widgets works with the second example.
Feel free to close the issue if this is intended.

legolasbo’s picture

This time I was able to reproduce the issue. Will look into what's causing it.

legolasbo’s picture

Status: Active » Needs review
FileSize
1.77 KB

Attached patch should fix the problem.

Since the initial commit, #disabled was handled by the module. I'm no expert on Drupal 6, but in Drupal 7, FAPI handles this.

legolasbo’s picture

Status: Needs review » Fixed

  • legolasbo committed eca7cae on 7.x-3.x
    Issue #2407567 by legolasbo: FAPI #disabled state not working on select...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.