form api
Cleaning Up Node Edit Forms
Submitted by greg.harvey on Mon, 12/10/2009 - 10:16Every time you build a new application in Drupal you *always* have to carefully govern the number of options available to normal site editors, or their heads will explode. (Literally. I've seen it.)
Almost every module you install will put something more on the node forms, until you end up scrolling forever just to reach the Save button. Not to mention most of this stuff you won't want them playing with anyway.
AHAH, Node Forms And Select Lists
Submitted by greg.harvey on Thu, 16/07/2009 - 09:35There are a number of decent resources helping you to make your first steps in to AHAH with Drupal 6.x. I won't try and create another start-to-finish tutorial. I just want to highlight a couple of existing resources and raise some specific issues I had (which I found to be undocumented) and pull out some fundamentals so they are more obvious.
Firstly, this page on Drupal.org is by far an away the most useful resource I found:
http://drupal.org/node/331941
Secondly, the Form API reference guide's section on #ahah is most handy too:
drupal_execute Gotcha In Drupal 6.x
Submitted by greg.harvey on Wed, 27/08/2008 - 18:24Many of you are probably familiar with drupal_execute(). However, those familiar with it from Drupal 5.x days will have to watch a new feature in Drupal 6.x.
Here's an example of an item in a hook_menu() implementation in the Taxonomy module for Drupal 6.x:
<?php
$items['admin/content/taxonomy/add/vocabulary'] = array(
'title' => 'Add vocabulary',
'page callback' => 'drupal_get_form',
'page arguments' => array('taxonomy_form_vocabulary'),
Form Redirection: A Special Case
Submitted by greg.harvey on Tue, 08/04/2008 - 20:32Most of you are probably familiar with using the Form API (either via hook_form_alter or when building your own form) to set the destination a user is sent to after submitting a form.
<?php
function mymodule_form_alter($form_id, &$form) {
if ($form_id == 'page_node_form') {
$form['#redirect'] = 'my/new/page';
}
}
?>This usually works, but today I came across a special case.
What if you want to redirect users back to the referring page after they submit a new node? Sounds simple enough, right? You'd probably do something like this:
<?php

