I was looking for the disabled option for a Numeric field, and couldn't find it - then realized that Numeric fields don't actually have that option as yet (6.x-3.18). As for other field types, I think there's a good rationale for having the option to disable a numeric field. In this case, I am populating some numeric fields by adding up others - so the target fields shouldn't be able to be edited.

Related tickets:

Comments

dbassendine’s picture

Here's a patch which adds this option to components/number.inc, based on textfield.inc. Patch is against 6.x-3.18.

dbassendine’s picture

This patch applies properly against 6.x-3.x

dbassendine’s picture

Status: Active » Needs review

Marking for review.

quicksketch’s picture

Status: Needs review » Fixed

Thanks! I changed one small part that changes the way the field is displayed when it's in its "unfiltered" form:

  // Set readonly if disabled.
  if ($component['extra']['disabled']) {
    if ($filter) {
      $element['#attributes']['readonly'] = 'readonly';
    }
    else {
      $element['#disabled'] = TRUE;
    }
  }

This affects the display of Form Builder only, which is the only situation where $filter is FALSE. The disabled status gives the field additional visual weight. This matches the implementation of textfields.

Committed to all branches.

Status: Fixed » Closed (fixed)

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