function commerce_store_field_widget_form_alter in Commerce Core 8.2
Implements hook_field_widget_form_alter().
File
- modules/
store/ commerce_store.module, line 41 - Defines the Store entity and associated features.
Code
function commerce_store_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {
/** @var \Drupal\Core\Field\BaseFieldDefinition $field_definition */
$field_definition = $context['items']
->getFieldDefinition();
$field_name = $field_definition
->getName();
$entity_type = $field_definition
->getTargetEntityTypeId();
$widget_name = $context['widget']
->getPluginId();
if ($field_name == 'billing_countries' && $entity_type == 'commerce_store' && $widget_name == 'options_select') {
$element['#options']['_none'] = t('- All countries -');
$element['#size'] = 5;
}
elseif ($field_name == 'path' && $entity_type == 'commerce_store' && $widget_name == 'path') {
$element['alias']['#description'] = t('The alternative URL for this store. Use a relative path. For example, "/my-store".');
}
}