提交后显示表单数据
我有一个带有提交按钮的表单和一个将数据存储在数据库中的处理程序。问题是提交表单后,输入字段中的所有数据都会被清除。有没有办法在提交后仍然显示它们?我需要对 form_submit 函数进行哪些更改?
function mymodule_form_submit($form, &$form_state) {
//how to retain the input in the form
}
我正在寻找最“drupalish”的方式来完成这件事?
I have a form with a submit button and a handler that stores data in the database. Problem is when the form is submitted, all data is cleared from the input fields. Is there a way to still show them after submit? 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
}
I'm looking for the most "drupalish" way to get this done?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如 之前的 StackOverflow 问题<所示/a> 您可以使用 $form_state['storage'] 和 $form_state['rebuild'] 来完成此操作。
As indicated by this previous StackOverflow question you can accomplish this with $form_state['storage'] and $form_state['rebuild'].
您可以使用
$_REQUEST['form_variable_name']
访问数据,其中form_variable_name
是 html 输入标记的名称。然后,您需要渲染页面,并将该值放入输入标签值字段中。
You can access the data using
$_REQUEST['form_variable_name']
whereform_variable_name
is the name of the html input tag.You then need to render the page back putting this value into the input tags value field.