Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By rakibtg on
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
I think you missing render the remain of form
I think you are missing render the remain of form (include hidden security key... and hidden fields). Include this code in the end
Exactly that was. I figured
Exactly that was. I figured it by printing token, form id and other key....
It doesn't work!
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
Solved
I solved using
<?php print drupal_render_children($form); ?>
Thanks,
WaPoNe
Not bad solution but...
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).
Thanks
Gajendra sharma
Solved It (node have problem)
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']);
Thanks
Gajendra Sharma