public function StoreForm::form in Commerce Core 8.2
Gets the actual form array to be built.
Overrides ContentEntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- modules/
store/ src/ Form/ StoreForm.php, line 16
Class
Namespace
Drupal\commerce_store\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/** @var \Drupal\commerce_store\Entity\StoreInterface $store */
$store = $this->entity;
$form['path_settings'] = [
'#type' => 'details',
'#title' => $this
->t('URL path settings'),
'#open' => !empty($form['path']['widget'][0]['alias']['#default_value']),
'#group' => 'advanced',
'#access' => !empty($form['path']['#access']) && $store
->get('path')
->access('edit'),
'#attributes' => [
'class' => [
'path-form',
],
],
'#attached' => [
'library' => [
'path/drupal.path',
],
],
'#weight' => 91,
];
$form['path']['#group'] = 'path_settings';
if (isset($form['is_default'])) {
$form['is_default']['#group'] = 'footer';
$form['is_default']['#disabled'] = $store
->isDefault();
if (!$store
->isDefault()) {
/** @var \Drupal\commerce_store\StoreStorageInterface $store_storage */
$store_storage = $this->entityTypeManager
->getStorage('commerce_store');
$default_store = $store_storage
->loadDefault();
if (!$default_store || $default_store
->id() == $store
->id()) {
$form['is_default']['widget']['value']['#default_value'] = TRUE;
}
}
}
return $form;
}