protected function ScriptForm::buildVisibilityForm in Script Manager 8
Build the visibility form.
1 call to ScriptForm::buildVisibilityForm()
- ScriptForm::form in src/
Form/ ScriptForm.php - Gets the actual form array to be built.
File
- src/
Form/ ScriptForm.php, line 129
Class
- ScriptForm
- The script entity add form.
Namespace
Drupal\script_manager\FormCode
protected function buildVisibilityForm(FormStateInterface $form_state) {
$form['visibility_tabs'] = [
'#type' => 'vertical_tabs',
'#title' => $this
->t('Visibility'),
'#parents' => [
'visibility_tabs',
],
'#attached' => [
'library' => [
'block/drupal.block',
],
],
];
$visibility_configuration = $this->entity
->getVisibilityConditions()
->getConfiguration();
foreach ($this
->getEnabledVisibilityDefinitions() as $condition_id => $definition) {
$condition = $this->conditionManager
->createInstance($condition_id, isset($visibility_configuration[$condition_id]) ? $visibility_configuration[$condition_id] : []);
$form_state
->set([
'conditions',
$condition_id,
], $condition);
$form[$condition_id] = [
'#type' => 'details',
'#title' => $condition
->getPluginDefinition()['label'],
'#group' => 'visibility_tabs',
] + $condition
->buildConfigurationForm([], $form_state);
}
return $form;
}