【发布时间】:2013-05-16 15:52:16
【问题描述】:
问题:
在 Drupal 7 的表单 API 中,当使用 #AJAX 刷新字段时,在刷新整个页面之前不会显示来自验证的错误消息。我看到我刷新的字段在错误状态下突出显示,但用户直到为时已晚(他们重新加载页面或转到另一个页面)时才看到相关消息。
我开始手动处理这个庄园的错误堆栈:Drupal.org -- Filter out specific errors during validation,但是我的表格比较复杂,完成这个任务的时间预算不多。必须有某种方法来刷新堆栈并向用户显示消息,而无需手动处理所有内容。
注意: 我正在使用带有回调的多命令,因此使用它是我的一个选项。
$commands[] = ajax_command_replace("#my_wrapper", render($form['test']['field_a']));
$commands[] = ajax_command_replace("#another_wrapper", render($form['test']['field_b']));
return array('#type' => 'ajax', '#commands' => $commands);
想法?
【问题讨论】:
标签: ajax drupal drupal-fapi