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.