Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/neo4j/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Drupal 7 Drupal按钮与form alter一起添加导致common.inc中出现致命错误_Drupal 7_Form Api - Fatal编程技术网

Drupal 7 Drupal按钮与form alter一起添加导致common.inc中出现致命错误

Drupal 7 Drupal按钮与form alter一起添加导致common.inc中出现致命错误,drupal-7,form-api,Drupal 7,Form Api,我正在使用Drupal 7中的form alter向节点表单添加另一个按钮: function mymod_form_alter(&$form, &$form_state, $form_id) { $form[$key]['button'] = array( '#type' => 'submit', '#value' => t('Seach), '#limit_validation_errors' => array(), '#

我正在使用Drupal 7中的form alter向节点表单添加另一个按钮:

function mymod_form_alter(&$form, &$form_state, $form_id) {
  $form[$key]['button'] = array(
    '#type' => 'submit',
    '#value' => t('Seach),
    '#limit_validation_errors' => array(),
    '#submit' => array('mymod_process'),
  );
 }

...
...

function mymod_process(&$form, &$form_state) {
  $form_state['rebuild'] = TRUE;    
  // Do my processing here...
}
我添加了
$form_state['rebuild']=TRUE
在按下按钮时保留表单值。第一次按下按钮时,此功能正常,第二次按下自定义按钮时,出现以下错误:

PHP Fatal error:  Cannot create references to/from string offsets nor overloaded objects in /www/includes/common.inc on line 6430
然后,当我重新加载页面时,drupal_set_message()会报告以下内容:

Notice: Array to string conversion in drupal_attributes() (line 2298 of /www/includes/common.inc).

如果我取出
$form_state['rebuild']=TRUE,错误消失。但是表单值不会被保留。你知道如何在不出现此错误的情况下保留表单值吗?

我遇到了一个类似的问题,我把
“#limit_validation_errors”=>array(),
和表单值放在了不保留的地方。如果去掉这一行,表单值实际上会保留下来

见:

这通常用于多步骤表单中的“后退”按钮,例如,“限制验证错误”=>array()意味着不验证任何内容,因为当前页面上的表单值无论如何都将被丢弃