Templating a Drupal Form

I was attempting to customize the look of a form that I create in a module using Drupal. I wanted to add images to a check box form element. This was a very useful link that explained how to call the form via the form id in the template.php file which then allows you to create a form.tpl.php file for custom styling.
http://drupal.org/node/62888#comment-119263

Great find

This is a great link! I remember when Dave and I were trying to figure out how to do this when we started The Vineyard Voice and ended up doing almost this. We went about it a slightly different way, instantiating the function only when the args were right. In this way we could have separate tpl files for the 'add' and the 'edit' forms. Here's a piece of what I mean:


/**
* VIDEO ADD
*/
if ((arg(0) == 'node') && (arg(1) == 'add') && (arg(2) == 'video')) {
function phptemplate_node_form($form) {
return _phptemplate_callback('video_add', array('user' => $user, 'form' => $form));
}
}


/**
* VIDEO EDIT
*/
if ((arg(0) == 'node') && (arg(2) == 'edit')) {
$node = node_load(array('nid' => arg(1)));
if ($node->type == 'video') {
function phptemplate_node_form($form) {
return _phptemplate_callback('video_edit', array('form' => $form));
}
}
}

The technique in the link you sent is much cleaner and our code could be improved upon quite a bit.

I too was trying to figure

I too was trying to figure out how to do this when we started The Vineyard Voice and ended up doing almost this. We went about it a slightly different way, instantiating the function only when the args were right. In this way we could have separate tpl files for the 'add' and the 'edit' forms. Here's a piece of what I mean: social bookmarking tool

I too was trying to figure

I too was trying to figure out how to do this when we started The Vineyard Voice and ended up doing almost this. We went about it a slightly different way, instantiating the function only when the args were right. In this way we could have separate tpl files for the 'add' and the 'edit' forms. Here's a piece of what I mean:
Essay Writing | Research Paper | Political Science Dissertation

Thanks! I'm a new drupal fan

Thanks!

I'm a new drupal fan and i'm theming like crazy!

Is it me or drupal is a HUGE phenomenon??

Thanks god for that little drop of water!!

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.