I have created a custom node add form for story content type. Though this appears as expected but do not working.
Problem is when i click on the Submit button then this form just redirect me again in node/add/story path instead creating the story page!
Here is what i have did (Here i have used bartik theme):

template.php

    function bartik_theme() {
    return array(
    'story_node_form' => array(
    'arguments' => array('form' => NULL),
    'template' => 'story-node-form',
    'render element' => 'form',
    ),
    );
story-node-form.tpl.php
<div class='story-form'>
<div><?php print drupal_render($form['title']); ?></div>
<div><?php print drupal_render($form['body']); ?></div>
<div><?php print drupal_render($form['actions']); ?></div>
<div><?php print drupal_render($form['additional_settings']); ?></div>
<div><?php print drupal_render($form['actions']); ?></div>
</div>

Now if i click on the Submit button then this story creating form just redirect me again in node/add/story path instead creating the story page! What i am missing here? Thanks ( i have also posted this on drupal stackexchange site )

Comments

vietdrupal’s picture

I think you are missing render the remain of form (include hidden security key... and hidden fields). Include this code in the end

.....
<div><?php print drupal_render($form['additional_settings']); ?></div>
<div><?php print drupal_render($form['actions']); ?></div>
<div><?php print drupal_render($form); ?></div>
.....
rakibtg’s picture

Exactly that was. I figured it by printing token, form id and other key....

WaPoNe’s picture

Hi,
I inserted also <div><?php print drupal_render($form); ?></div> row but it doesn't work!
It doesn't load the page that results blank! :(

WaPoNe

WaPoNe’s picture

I solved using
<?php print drupal_render_children($form); ?>

Thanks,
WaPoNe

gsharm’s picture

Because drupal_render_children($form) show all form fields but need's image and title fields show in node form edit tpl.
You can render ( $form['form_id, $form['form_build_id'] and $form['form_token']) and render $form['actions'] form fields in your form tpl file like(article_node_form.tpl.php).

print render($form['form_id']); 
print render($form['form_build_id']); 
print render ($form['form_token']);

print render($form['field_image']);
print render($form['title']);

print render ($form['actions']);

Thanks
Gajendra sharma

gsharm’s picture

You can render ( $form['form_id, $form['form_build_id'] and $form['form_token']) and render $form['actions'] form fields in your form tpl file like(article_node_form.tpl.php).

print render($form['form_id']);

 print render($form['form_build_id']); 
print render ($form['form_token']);
print_r($form);

print render($form['field_image']);
print render($form['body']);
print render($form['title']);
print drupal_render($form['actions']);
print render($form['submit']);

Thanks
Gajendra Sharma