In the ancient times when things were easy, you just had to code a form in html and then your php would typically have a if($_REQUEST['some_value']) to handle the request. But now with Drupal, nothing is easy... Here is once more my latest battle to understand how Drupal thinks.
Context: I have a list of news (content type "news") shown on a page with paging system. Each news title links to the news details page. This works fine. There is a new requirement that each news must have one or more "tags". The goal is to show a list of checkboxes on top of the news list to allow the user to filter in/out news with the selected tags.
EDIT: After being defeated by Drupal's form I decided to completely bypass the Form API and generate my own fully flexible form.
There is only one thing remaining, Drupal is forcing some div wrappers around each of my input fields. I want to get rid of them (and stop Drupal to think at my place).
In my_news_list.tpl.php I coded:
<form action="" method="post"> <!-- recall same page on submit --> <?php foreach($tags as $tag){ ?><input type="checkbox" name="tags[]" value="<?php echo $tag['id'] ?>" onchange="form.submit();" <?php if(isset($tag['checked'])){?>checked="checked"<?php }?> /><?php echo $tag['value'] ?><?php } ?> </form> Result(!):
<form action="" method="post"> <div class=" ui-checkbox"> <!-- Why those div wrappers?! --> <input type="checkbox" name="tags[]" value="15" onchange="form.submit();"> </div> Acquisitions <div class=" ui-checkbox"> <input type="checkbox" name="tags[]" value="14" onchange="form.submit();"> </div> Corporate <div class=" ui-checkbox"> <input type="checkbox" name="tags[]" value="18" onchange="form.submit();"> </div> Investor News <div class=" ui-checkbox"> <input type="checkbox" name="tags[]" value="16" onchange="form.submit();"> </div> Products and Services </form>