public function SiteSettingEntityForm::buildForm in Site Settings and Labels 8
Form constructor.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form structure.
Overrides EntityForm::buildForm
File
- src/
Form/ SiteSettingEntityForm.php, line 61
Class
- SiteSettingEntityForm
- Form controller for Site Setting edit forms.
Namespace
Drupal\site_settings\FormCode
public function buildForm(array $form, FormStateInterface $form_state) {
/* @var $entity \Drupal\site_settings\Entity\SiteSettingEntity */
$form = parent::buildForm($form, $form_state);
$site_settings_entity_type = SiteSettingEntityType::load($this->entity
->getType());
$form['heading1'] = [
'#markup' => '<h2>' . $site_settings_entity_type
->get('label') . '</h2>',
'#weight' => -100,
];
// Set entity title and fieldset to match the bundle.
$form['name']['widget'][0]['value']['#value'] = $site_settings_entity_type
->get('label');
$form['fieldset']['widget'][0]['value']['#value'] = $site_settings_entity_type
->get('fieldset');
// Hide fields.
hide($form['name']);
hide($form['user_id']);
hide($form['fieldset']);
if (isset($form['multiple'])) {
hide($form['multiple']);
}
return $form;
}