diff --git a/field_collection.install b/field_collection.install index adb6225..1a86a60 100644 --- a/field_collection.install +++ b/field_collection.install @@ -331,6 +331,29 @@ function field_collection_update_7006() { } /** + * Add index on {$field_collection_field}_value column for all tables. + */ +function field_collection_update_7007() { + foreach (field_read_fields(array('type' => 'field_collection')) as $field_name => $field) { + if (!isset($field['indexes']['value'])) { + // Add index on the value column and update the field. + $field['indexes']['value'] = array('value'); + field_update_field($field); + } + + $table_prefixes = array('field_data', 'field_revision'); + foreach ($table_prefixes as $table_prefix) { + $table = "{$table_prefix}_{$field_name}"; + $value_column = "{$field_name}_value"; + if (!db_index_exists($table, $value_column)) { + // Add index on the value column. + db_add_index($table, $value_column, array($value_column)); + } + } + } +} + +/** * Update fields in field collections already set to use Entity Translation. */ function field_collection_update_7007() { @@ -358,26 +381,3 @@ function field_collection_update_7007() { } } } - -/** - * Add index on {$field_collection_field}_value column for all tables. - */ -function field_collection_update_7007() { - foreach (field_read_fields(array('type' => 'field_collection')) as $field_name => $field) { - if (!isset($field['indexes']['value'])) { - // Add index on the value column and update the field. - $field['indexes']['value'] = array('value'); - field_update_field($field); - } - - $table_prefixes = array('field_data', 'field_revision'); - foreach ($table_prefixes as $table_prefix) { - $table = "{$table_prefix}_{$field_name}"; - $value_column = "{$field_name}_value"; - if (!db_index_exists($table, $value_column)) { - // Add index on the value column. - db_add_index($table, $value_column, array($value_column)); - } - } - } -} diff --git a/field_collection.module b/field_collection.module index a64b14c..2939e9f 100644 --- a/field_collection.module +++ b/field_collection.module @@ -1413,6 +1413,10 @@ function field_collection_field_widget_embed_validate($element, &$form_state, $c } } } + + // Attach field API validation of the embedded form. + field_attach_form_validate('field_collection_item', $field_collection_item, $element, $form_state); + // Handle a possible language change. if (field_collection_item_is_translatable()) { $handler = entity_translation_get_handler('field_collection_item', $field_collection_item); @@ -1421,9 +1425,6 @@ function field_collection_field_widget_embed_validate($element, &$form_state, $c $handler->entityFormLanguageWidgetSubmit($element, $element_form_state); } - // Attach field API validation of the embedded form. - field_attach_form_validate('field_collection_item', $field_collection_item, $element, $form_state); - // Now validate required elements if the entity is not empty. if (!field_collection_item_is_empty($field_collection_item) && !empty($element['#field_collection_required_elements'])) { foreach ($element['#field_collection_required_elements'] as &$elements) {