Drupal无法做到这一点? “不能”不在我的词汇量中!
我有同样的问题,但我不能让它打败我。以下是我挺过来了:
在处理表格后,我插入的细节到数据库(或电子邮件或其他),我设置2条Drupal的状态消息像这样
function process_form($form){
$success = do_email($form);
if ($success){
drupal_set_message("Success");
drupal_set_message("Your form worked!");
}
}
并在窗体发电机我读并清除邮件,清除表单和输出状态消息为标记:
function form_generator($form_state,$parameters){
$form = array();
...// This is where I make the regular form
$messages = drupal_get_messages(); // this gets the messages and clears them
if (isset($messages["status"])){
if (isset($messages['status'][0]) && isset($messages['status'][1])){
if ($messages['status'][0]=="Success"){
$form = array(); // This clears the form I've just made
$form['final_message']= array(
'#type' => 'markup',
'#markup' => $messages['status'][1],
);
}
}
}
}
这不清除表单第一次它的显示,因为$消息未设置,当你遇到验证他们仍然会出现错误。
Drupal magic magic我们的方式,但PHP编码器的意志更强。
+1 - 我发布了一个更详细的答案,但这是解决问题的正确方法。 – 2010-10-07 07:21:04