I have Botcha installed. When I click on request new password, the modal form displays fields that should be hidden. How do I hide them?

Comments

Anton.Safin’s picture

Set "Recipe book: AJAX Frendly" for login/register forms on BOTCHA configuration page (/admin/config/people/botcha/form)

hughworm’s picture

This comes down to Drupal ajax not currently supporting inline css. See ajax.inc where a comment states:

      // @todo Inline CSS and JS items are indexed numerically. These can't be
      //   reliably diffed with array_diff_key(), since the number can change
      //   due to factors unrelated to the inline content, so for now, we strip
      //   the inline items from Ajax responses, and can add support for them
      //   when drupal_add_css() and drupal_add_js() are changed to use a hash
      //   of the inline content as the array key.

So for example this doesn't work in a modal form:

    $form['#attached']['js'][] = array(
      'data' => 'alert("Hello")',
      'type' => 'inline',
    );

But this does:

    $form[] = array(
      '#markup' => '<script>alert("Hello")</script>',
    );

So I've patched BOTCHA to use the #markup version when the form is under ajax, and it seems to work. Let me know if you'd like to the patch.