public function StyleguidePatternForm::form in Simple Style Guide 8
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ StyleguidePatternForm.php, line 26
Class
- StyleguidePatternForm
- Class StyleguidePatternForm.
Namespace
Drupal\simple_styleguide\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$styleguide_pattern = $this->entity;
$form['label'] = [
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $styleguide_pattern
->label(),
'#description' => $this
->t("Label for the Styleguide pattern."),
'#required' => TRUE,
];
$form['description'] = [
'#type' => 'text_format',
'#title' => $this
->t('Description'),
'#format' => 'full_html',
'#rows' => 5,
'#default_value' => $styleguide_pattern->description['value'] ?: '',
];
$form['pattern'] = [
'#type' => 'textarea',
'#title' => $this
->t('Pattern'),
'#rows' => 15,
'#default_value' => $styleguide_pattern->pattern,
'#description' => $this
->t('Paste in your raw html.'),
];
$form['id'] = [
'#type' => 'machine_name',
'#default_value' => $styleguide_pattern
->id(),
'#machine_name' => [
'exists' => '\\Drupal\\simple_styleguide\\Entity\\StyleguidePattern::load',
],
'#disabled' => !$styleguide_pattern
->isNew(),
];
/* You will need additional form elements for your custom properties. */
return $form;
}