diff --git a/commerce_backoffice_product.module b/commerce_backoffice_product.module index 9a8dad9..f32dcbb 100644 --- a/commerce_backoffice_product.module +++ b/commerce_backoffice_product.module @@ -230,6 +230,23 @@ function theme_commerce_backoffice_product_node_add_list($variables) { } /** + * Implements hook_form_field_ui_field_edit_form_alter(). + * For extra field instance settings. + */ +function commerce_backoffice_product_form_field_ui_field_edit_form_alter(&$form) { + // For term reference fields of Product displays Only. + if ($form['#field']['type'] == 'taxonomy_term_reference' && in_array($form['#instance']['bundle'], array_keys(commerce_product_reference_node_types()))) { + $field = $form['#field']; + $form['instance']['not_product_catalog'] = array( + '#type' => 'checkbox', + '#title' => t('Not a product catalog?'), + '#default_value' => empty($form['#instance']['not_product_catalog']) ? 0 : 1, + '#description' => t('For term reference fields that should not be in the Product catalog Vertical tab.'), + ); + } +} + +/** * Implements hook_form_views_form_alter(). */ function commerce_backoffice_product_form_alter(&$form, &$form_state, $form_id) { @@ -253,7 +270,7 @@ function commerce_backoffice_product_form_alter(&$form, &$form_state, $form_id) foreach (field_info_instances('node', $form['#node']->type) as $field_name => $instance) { $field = field_info_field($field_name); - if ($field['type'] == 'taxonomy_term_reference') { + if ($field['type'] == 'taxonomy_term_reference' && (!isset($instance['not_product_catalog']) || !$instance['not_product_catalog'])) { $form[$field_name]['#fieldset'] = 'product_catalog'; } }