Displaying form data after submission

I have a form with a submit button and a handler that stores data in a database. The problem is when the form is submitted, all data is cleared of input fields. Is there any way to show them after sending? What changes do I need to make to my form_submit function?

function mymodule_form_submit($form, &$form_state) {
 //how to retain the input in the form
}

Am I looking for the most "drupalish" way to do this?

+3
source share
2 answers

As indicated by fooobar.com/questions/731680 / ... , you can accomplish this with $ form_state ['storage'] and $ form_state ['rebuild'].

+3
source

$_REQUEST['form_variable_name'], form_variable_name - html.

, .

<form method="POST" action="/account/contactdetails/">
 <div>
  <label>First name:</label>
  <input type="text" name="firstname" value="<?php echo $_REQUEST['firstname']; ?>" />
 </div>
 <div>
  <label>Last name:</label>
  <input type="text" name="lastname" value="<?php echo $_REQUEST['lastname']; ?>" />
 </div>
 <input type="submit" value="Save" />
</form>
0

Source: https://habr.com/ru/post/1761994/


All Articles