I have a case where I need to have a Clear button on a form that not only clears out the form it's on, but also clears out checkboxes in other forms and clears data from ctools_object_cache.

The page is a custom search page created by the apachesolr module. In the sidebar I have multiple blocks that are just 'checkboxes' form elements of taxonomy terms (each block is a separate vocabulary). The checkboxes are used to select terms, which are written to ctools_object_cache using #ajax in the form when selected. What I need is to have a Clear button (or link) on the search form that does a few things:

  • Clears the search field
  • Deletes items from ctools_object_cache
  • Deselects the checkboxes in the sidebar forms
  • Selects a specific checkbox in another sidebar block (labeled "All")

Is it possible to do this using a #ajax button with Forms API? Or do I need to just write it as a separate Drupal behavior in jQuery? I know Drupal forms can be handled in jQuery, but I haven't used it before, so I'm not sure where to start.


1 Answer 1


In talking to Randy Fay, this will not work for a number of reasons, of which security is a big one. Form API was written to avoid one form modifying other forms (among other things), so I re-architected the form elements to be all in one form instead of separate forms.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.