简体   繁体   English

Drupal表单提交,表单after_build

[英]Drupal form submit, form after_build

是什么区别$form['#submit']$form['#after_build']

The api docs lay this out fairly well. api文档很好地说明了这一点。 $form['#submit'] 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. $form['#submit']将向$form['#submit']添加一组提交处理程序:即当有人单击“提交”按钮时,将调用数组中的函数。 These will be called after submission . 这些将在提交后调用。

You generally would want to use this property when you are calling hook_form_alter() 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. 当你调用hook_form_alter()将另一个提交函数添加到你自己没有构建的表单上时,通常会想要使用这个属性,就像你自己在代码中创建表单一样,你也创建了默认的提交处理程序。 Here are the FAPI docs on #submit . 下面是对FAPI文档#submit

$form['#after_build'] 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. $form['#after_build']的类似之处在于它需要调用一系列函数,但是在构建表单以供显示之后它们将被调用。 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 FAPI docs for a good example of checking the status of something before submission, after the form is built to be displayed. 在构建要显示的表单之后,请参阅FAPI文档以获取在提交之前检查某些事物状态的良好示例。

So in summary, $form['#submit'] functions will be called upon submission, and $form['#after_build'] functions will be called upon display of the form. 总而言之, $form['#submit'] $form['#after_build']函数将在提交时被调用,并且$form['#after_build']函数将在显示表单时被调用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM