public ShortcutSetForm::form(array $form, FormStateInterface $form_state)
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- core/modules/shortcut/src/ShortcutSetForm.php, line 16
Class
- ShortcutSetForm
- Form handler for the shortcut set entity edit forms.
Namespace
Drupal\shortcut
Code
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$entity = $this->entity;
$form['label'] = array(
'#type' => 'textfield',
'#title' => t('Set name'),
'#description' => t('The new set is created by copying items from your default shortcut set.'),
'#required' => TRUE,
'#default_value' => $entity->label(),
);
$form['id'] = array(
'#type' => 'machine_name',
'#machine_name' => array(
'exists' => '\Drupal\shortcut\Entity\ShortcutSet::load',
'source' => array('label'),
'replace_pattern' => '[^a-z0-9-]+',
'replace' => '-',
),
'#default_value' => $entity->id(),
// This id could be used for menu name.
'#maxlength' => 23,
);
$form['actions']['submit']['#value'] = t('Create new set');
return $this->protectBundleIdElement($form);
}
Please login to continue.