hi,
i am using drupal 6,i would like to know whether there is any way to customize the node's add form in drupal6.
I know that page-node-add-[contenttype].tpl.php is the template to be taken but whats the way of getting the form elements in that.
previously in drupal 5 we used to get the form elements in the $form array. but in drupal6 its not available.

I could not figure out how to customize the node/add node/edit using that approach. Do anyone have a solution?

Comments

mndonx’s picture

Hi there - There are a couple ways to customize your Drupal forms. I have an example of how to customize the user login block by adding a form override in your template.php file -- you can use the same concept to make changes to your node edit form.

You can take it a step further and make a full-on tpl file for your node edit form: Here's an example of Theming the User Registration Form. (Please be sure to read the comments on that one because the tutorial leaves out some crucial information.)

Both of these examples can be adapted to your needs - let me know if you need further help doing that.

Thanks,
Amanda

OptimusPrime23’s picture

At last I fixed the issue...

The steps that i followed are :
1. Edit template.php

Add the following


function yourthemename_theme($existing, $type, $theme, $path) {
 return array(		  
		'contenttype1_node_form' => 
			array(
				'arguments' => array('form' => NULL),
				  'template' => 'contenttype1_add'  
			       ),
		'contenttype2_node_form'=>
				array(
					'arguments' => array('form' => NULL),
					'template' => 'contenttype2t_add',      
				       ),
                                                      .
                                                      .
                                                      .
                                                      .
                                                      .
                                                      .

  		);
}

2. Create content_type_add.tpl.php

Add the following

print '<pre>';
print_r($form);
print '</pre>';

the $form variable would contain all the necessary for values
3. "Clearing Cache Data before viewing the result" VERY IMPORTANT

All i was lacking was "Clearing Cache Data before viewing the result".

So anyone who is customizing the node's add form in Drupal 6 pls make sure to clear the cache.
Try this n explore drupal.have fun

Cheers,

Ninu Ann

jeuelc’s picture

It worked. made my task easier.

cheers!

DrupalDan’s picture

I don't know if it's just me but the above approach not working in drupal 7. I do the exactly thing and replace "yourthemename" in yourthemename_theme with my theme name and "contenttype1_node_form" with "testing_content_type_node_form". Is there anything else I need to change to make it work?

Thanks!

lidiia.litovko’s picture

I tryed do everything written in post by ninu_ann, but in Drupal 7 this not work. Anybody know how to customize add/edit node form for custom content type in Drupal 7?

DrupalDan’s picture

@lidiia.litovko any luck so far?

ktzocalo’s picture

As per this example:
http://alvinalexander.com/drupal/drupal-modify-page-node-title-custom-ne...

I added this to the theme template.php. Set the theme name and replace "charity" with the name of your content type.

/**
* Implementation of hook_form_alter().
* Modify the node title for my New Charity form.
*/
function YOURTHEMENAME_form_charity_node_form_alter(&$form, &$form_state) {

drupal_set_title('Suggest a Charity');

}

jeffburnes7’s picture

Been wondering how to go about it.
Web Design

pandersb’s picture

I'm using Drupal 7.24 and when I looked at the theme_hook_suggestions array for the page (page.tpl.php), I found that page__node__add__MYCONTENTTYPE was in the list. The same can be said for the html template suggestion.