Php 未定义索引:区域设置\字段\实体\表单\提交()中的自定义字段(区域设置模块的第438行)

Php 未定义索引:区域设置\字段\实体\表单\提交()中的自定义字段(区域设置模块的第438行),php,drupal-7,drupal-modules,drupal-fields,drupal-field-api,Php,Drupal 7,Drupal Modules,Drupal Fields,Drupal Field Api,您好,我在使用自定义字段创建自定义节点类型时遇到这种错误: 未定义索引:区域设置中的字段\块\预\u登录\正文\字段\实体\表单\提交()(D:\xampp\htdocs\projects\foo\modules\locale\locale.module的第438行) 自定义字段和自定义节点类型通过hook_install创建: function custom_module_install() { $nodeType = new stdClass(); $node

您好,我在使用自定义字段创建自定义节点类型时遇到这种错误:

未定义索引:区域设置中的字段\块\预\u登录\正文\字段\实体\表单\提交()(D:\xampp\htdocs\projects\foo\modules\locale\locale.module的第438行)

自定义字段和自定义节点类型通过hook_install创建:

function custom_module_install() {
        $nodeType = new stdClass();
        $nodeType->type = "foo_block";
        $nodeType->orig_type = "foo_block";
        $nodeType->base = "node_content";
        $nodeType->name = "FooBlock";
        $nodeType->description = $t("This is a Custom Content Type for Defining Custom blocks for Pre and Post Login State Functionality on blocks");
        $nodeType->help = "Use This Content Type only if the block will have a Login State requirements";
        $nodeType->custom = TRUE;
        $nodeType->has_title = TRUE;
        $nodeType->title_label = "Custom Block";
        $nodeType->locked = FALSE;
        $nodeType->disabled = FALSE;

        node_type_save($nodeType);
        if (!field_info_field('field_block_pre_login_body')) {
            $field = array(
                'field_name' => $t('field_block_pre_login_body'),
                'type' => 'text_long',
            );
            field_create_field($field);

            // Create the field instance on the bundle.
            $instance = array(
                'field_name' => $t('field_block_pre_login_body'),
                'label' => $t('Pre-Login Body'),
                'bundle' => 'matterhorn_block',
                'entity_type' => 'node',
                'required' => FALSE,
                'widget' => array('type' => 'text_textarea'),
                'settings' => array('text_processing' => 1),
                'format' => 'filter_html',
            );
            field_create_instance($instance);
        }
}
现在,当我在Drupal中安装了自定义模块,并通过我创建的自定义节点类型添加内容后,locale.module在创建或更新使用该内容类型创建的内容后会提示一个错误,您知道如何解决这个问题吗?谢谢

**编辑**


注意:这是drupal模块,我需要更详细的说明drupal field api如何使用它,因为调用
field\u block\u pre\u login\u body
方法后,会在索引中创建
field\u create\u field

您可以使用此修补程序:

diff --git a/modules/locale/locale.module b/modules/locale/locale.module
    index 768fead..39ae31f 100644
    --- a/modules/locale/locale.module
    +++ b/modules/locale/locale.module
    @@ -434,14 +434,16 @@ function locale_field_entity_form_submit($entity_type, $form, &$form_state ) {

         foreach (field_info_instances($entity_type, $bundle) as $instance) {
           $field_name = $instance['field_name'];
    -      $field = field_info_field($field_name);
    -      $previous_language = $form[$field_name]['#language'];
    -
    -      // Handle a possible language change: new language values are inserted,
    -      // previous ones are deleted.
    -      if ($field['translatable'] && $previous_language != $current_language) {
    -        $form_state['values'][$field_name][$current_language] = $entity->{$field_name}[$previous_language];
    -        $form_state['values'][$field_name][$previous_language] = array();
    +      if (!empty($form[$field_name])) {
    +        $field = field_info_field($field_name);
    +        $previous_language = $form[$field_name]['#language'];
    +
    +        // Handle a possible language change: new language values are inserted,
    +        // previous ones are deleted.
    +        if ($field['translatable'] && $previous_language != $current_language) {
    +          $form_state['values'][$field_name][$current_language] = $entity->{$field_name}[$previous_language];
    +          $form_state['values'][$field_name][$previous_language] = array();
    +        }
           }
         }
       }
请在

中阅读更多可能的副本