3

I am new to drupal, but i have a requirement with form submission .For this i have created a static block . In that block some input types are there like dropdown menu, checkboxes radio button etc. When user clicks on preview button i am able to fetch the data into bootstrap modal dialogue box.So in that modal dialogue form, submit button is there.But when i try to submit the values from modal dialogue box those values are not posted. Those values sent to url.

For this i am using normal $_POST method.

I have placed this code in the block section like regualr php .

if(isset($_POST['sendtorfq']) 
{
  print_r($_POST);
}


<form name="rfq_form id="rfq_form method="post">
  <input type="submit" class="btn btn-primary" name="sendtorfq" value="SendData">
</form>

But it takes form method as GET. and when i place the mouse on the submit button it shows the url of that page like /process?name=somename&email=someemail.Every time when i submit the form values are posted to url . But not to post method. Please suggest me where i was wrong?

0

4 Answers 4

1

I think you should work with Drupal forms api

But here you are missing some quotes in your html so it could be the issue your form is not working

--<form name="rfq_form id="rfq_form method="post">
  --<input type="submit" class="btn btn-primary" name="sendtorfq" value="SendData">
--</form>

TO

++<form name="rfq_form" id="rfq_form" method="post">
  ++<input type="submit" class="btn btn-primary" name="sendtorfq" value="SendData">
++</form>

Firebug your html in browser you will see it is breaking. Now it should work.

1

I would strongly recommend the Entityform module. Going with this module, would allow you to take advantage of the countless contributed modules that add fields via field ui. Like the most useful for you would be the Rules and Views modules.

Rules would be used to create custom conditional actions when your form is submitted and Views would allow you to create custom displays using form submissions.

0

I completely disagree with this method you did, you can achieve it by more better and clear solution,like using great webform module, by the way I suggest you add action property to your form, also register a callback menu to receive and process your data.

0

Get yourself familiar with Drupal Form API if you want tight control on custom form. Or like what zhilevan has suggested, (which I totally agree—no need to reinvent the wheel) use Webform module. 421,374 sites and over 2 million downloads! Can't go wrong with security and guaranteed peer reviewed by a lot of people for awesomeness.

Some relevant reads:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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