Bean 模块无法添加数据

当我添加block时出现这样的错误:

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '0' for key 2: INSERT INTO {bean} (vid, delta, label, title, type, view_mode, data) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array ( [:db_insert_placeholder_0] => 0 [:db_insert_placeholder_1] => test33 [:db_insert_placeholder_2] => test33 [:db_insert_placeholder_3] => test33 [:db_insert_placeholder_4] => home_introduction [:db_insert_placeholder_5] => default [:db_insert_placeholder_6] => a:1:{s:9:"view_mode";s:7:"default";} ) in drupal_write_record() (line 7106 of /var/www/dev/xkzhou/si/includes/common.inc).

Bean Error

在Views handlers中字段没有初始化

在Views Sort中field没有字段初始化, 在Filter handler中。如果你想使用$this->query->fields 这是不可能的。因为现在他还是一个空数组。并没有初始化, 这个fields 是你add_field添加的字段,如果你要使用你就必须初始化

解决方案:

//这样就可以初始化你的field
$this->view->_build('field');

options_form算是最开始运行的,所以如果你要在这里面使用$this->query->fields,你还需要初始化handlers和query

$this->view->init_handlers();      
$this->view->init_query();
$this->view->_build('field');