After I changed my admin theme to bootstrap, my forms #states stopped working. When I looked into it I found that ID selector was not added to the form element "item". I have used form type "item" to wrap around some form elements and to display/hide those elements based on a radio button. So the #markup is empty.

bootstrap_form_element in form-element.fun.php does not add wrapper id if #markup is empty.

  // Add wrapper ID for 'item' type.
  if ($type && $type === 'item' && !empty($element['#markup']) && !empty($element['#id'])) {
    $wrapper_attributes['id'] = $element['#id'];
  }

I checked in includes/forms.inc, there it checks only for isset before adding ID.

// Add element #id for #type 'item'.
  if (isset($element['#markup']) && !empty($element['#id'])) {
    $attributes['id'] = $element['#id'];
  }

Is there any reason why we check if markup is empty before adding wrapper ID? Can we patch it with isset?

CommentFileSizeAuthor
#3 states_js_not_working-2887742-3.patch568 byteszuhair_ak

Comments

zuhair_ak created an issue. See original summary.

markhalliwell’s picture

Version: 7.x-3.14 » 7.x-3.x-dev

Can we patch it with isset?

Please feel free to create a patch. I will gladly commit this change.

zuhair_ak’s picture

StatusFileSize
new568 bytes

Added the patch. Thanks for the reply.

markhalliwell’s picture

Status: Active » Fixed

Sorry this took so long. For future reference, you should set the status of an issue to "Needs review" when there's a patch on it. Otherwise, its priority is bumped for those that have that status and why I'm just now getting around to the "Active" backlog.

  • markcarver committed 54544ac on 7.x-3.x authored by zuhair_ak
    Issue #2887742 by zuhair_ak: states.js not working for form type "item"...
zuhair_ak’s picture

I had forgotten to change the status to "Need Review". Thanks Mark for noticing and committing it.

Status: Fixed » Closed (fixed)

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