0

I have created a form using Drupal 7 Form API. For this I have a cancel link to redirect back to that page from where it comes. This works fine until I do not submit the form: after form submission the cancel link is redirecting me to the same form.

<div class="row">
<?php print render($form['name']); ?>
</div>
<div class="row">
<?php print render($form['email']); ?>
</div>
<div class="row">
<?php print render($form['quantity']); ?>
</div>
<div class="row">
<?php print render($form['comments']); ?>
</div>
<div class="btn-area">
<?php print render($form['submit']);?>
<?php print render($form['buttons']);?>
<?php if($form): 
print drupal_render_children($form); 
endif;
$node_url= $_POST['node_url'];
print "<div class='rfq-btn'><a class='btn-close' href='$node_url'>Cancel</a>  </div>";
  • 1
    How do you set $_POST['node_url']? – Huelfe Nov 26 '15 at 10:38
  • I have a html form on another page, using POST method to post the value of current url of that node for cancel link – nomeer Nov 26 '15 at 10:41
  • You could use <input type="hidden" name="node_url" value="<?php echo $_POST['node_url']; ?>" />. – Huelfe Nov 26 '15 at 10:44
  • I used it before but after form submission its value also disappears – nomeer Nov 26 '15 at 10:47
  • Make sure your input field is in the form element. – Huelfe Nov 26 '15 at 10:52

Your Answer

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

Browse other questions tagged or ask your own question.