2

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

  • 1
    You really shouldn't be doing stuff like that in the theme layer. You want to create a custom form use the form api inside of a custom module or modify the existing form using hook_form_alter also in a custom module not the theme. api.drupal.org/api/drupal/… – danielson317 Jul 15 '13 at 20:50
  • 1
    It's recommended to do this in the theme layer, actually. You're just missing the hidden input fields like the form CSRF token, the form's ID, etc. Try adding <?php print drupal_render_children($form); ?> in your tpl. – Charlie Schliesser Feb 18 '14 at 22:07
0

I have solved this by doing <?php print kpr($form); ?> and put all the hidden input fields in the form like token, form_id etc that worked!

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.