Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 441 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Drupal form submit, form after_build

#1
What is the difference between `$form['#submit']` and `$form['#after_build']`?
Reply

#2
The api docs lay this out fairly well. <code>$form['#submit']</code> will add an array of submit handlers to your form: ie when someone clicks the "Submit" button the function in the array will be called. These will be called **after submission**.

You generally would want to use this property when you are calling <code>hook_form_alter()</code> to add another submit function on to a form that you didn't build yourself, as if you create the form yourself in code, you also create the default submit handler.
<a href="http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#submit-prop">Here</a> are the FAPI docs on `#submit`.


<code>$form['#after_build']</code> is similar in that it takes an array of of functions to call, but they will be called after the form is built for display. This can be used if you have a default or existing value in a form element, and want to check the status of something with that value **before submission**. See the <a href="http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html/6#after_build">FAPI</a> docs for a good example of checking the status of something before submission, after the form is built to be displayed.

So in summary, `$form['#submit']` functions will be called upon submission, and `$form['#after_build']` functions will be called upon display of the form.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through