diff --git a/includes/commerce_product.inline_entity_form.inc b/includes/commerce_product.inline_entity_form.inc index 9c8f96b..6029e0a 100644 --- a/includes/commerce_product.inline_entity_form.inc +++ b/includes/commerce_product.inline_entity_form.inc @@ -209,6 +209,24 @@ class CommerceProductInlineEntityFormController extends EntityInlineEntityFormCo $entity_form['sku']['#description'] = t('Will be auto-generated when the form is saved.'); } } + + // Allow the Automatic Entity Label module to handle the title. + if (module_exists('auto_entitylabel')) { + if (auto_entitylabel_is_needed($product, 'commerce_product')) { + $settings = _auto_entitylabel_get_settings($product, 'commerce_product'); + $setting = auto_entitylabel_get_setting($settings['key']); + if ($setting == AUTO_ENTITYLABEL_ENABLED || ($setting == AUTO_ENTITYLABEL_OPTIONAL && empty($product->{$settings['title']}))) { + if ($setting == AUTO_ENTITYLABEL_OPTIONAL) { + $entity_form['title']['#required'] = FALSE; + } + if ($setting == AUTO_ENTITYLABEL_ENABLED) { + $entity_form['title']['#required'] = FALSE; + $entity_form['title']['#access'] = FALSE; + } + } + } + } + // Hide the title field if it is auto-generated. if ($this->settings['autogenerate_title']) { $entity_form['title']['#required'] = FALSE; diff --git a/includes/node.inline_entity_form.inc b/includes/node.inline_entity_form.inc index b9632cd..b2db83f 100644 --- a/includes/node.inline_entity_form.inc +++ b/includes/node.inline_entity_form.inc @@ -40,6 +40,23 @@ class NodeInlineEntityFormController extends EntityInlineEntityFormController { '#weight' => -5, ); + // Allow the Automatic Entity Label module to handle the title. + if (module_exists('auto_entitylabel')) { + if (auto_entitylabel_is_needed($node, 'node')) { + $settings = _auto_entitylabel_get_settings($node, 'node'); + $setting = auto_entitylabel_get_setting($settings['key']); + if ($setting == AUTO_ENTITYLABEL_ENABLED || ($setting == AUTO_ENTITYLABEL_OPTIONAL)) { + if ($setting == AUTO_ENTITYLABEL_OPTIONAL) { + $entity_form['title']['#required'] = FALSE; + } + if ($setting == AUTO_ENTITYLABEL_ENABLED) { + $entity_form['title']['#required'] = FALSE; + $entity_form['title']['#access'] = FALSE; + } + } + } + } + field_attach_form('node', $node, $entity_form, $form_state, LANGUAGE_NONE); return $entity_form;