public function ContentModerationStateForm::buildConfigurationForm in Drupal 10
Same name and namespace in other branches
- 8 core/modules/content_moderation/src/Form/ContentModerationStateForm.php \Drupal\content_moderation\Form\ContentModerationStateForm::buildConfigurationForm()
- 9 core/modules/content_moderation/src/Form/ContentModerationStateForm.php \Drupal\content_moderation\Form\ContentModerationStateForm::buildConfigurationForm()
Form constructor.
Plugin forms are embedded in other forms. In order to know where the plugin form is located in the parent form, #parents and #array_parents must be known, but these are not available during the initial build phase. In order to have these properties available when building the plugin form's elements, let this method return a form element that has a #process callback and build the rest of the form in the callback. By the time the callback is executed, the element's #parents and #array_parents properties will have been set by the form API. For more documentation on #parents and #array_parents, see \Drupal\Core\Render\Element\FormElement.
Parameters
array $form: An associative array containing the initial structure of the plugin form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form. Calling code should pass on a subform state created through \Drupal\Core\Form\SubformState::createForSubform().
Return value
array The form structure.
Overrides PluginFormInterface::buildConfigurationForm
File
- core/
modules/ content_moderation/ src/ Form/ ContentModerationStateForm.php, line 19
Class
- ContentModerationStateForm
- The content moderation state form.
Namespace
Drupal\content_moderation\FormCode
public function buildConfigurationForm(array $form, FormStateInterface $form_state, StateInterface $state = NULL) {
/** @var \Drupal\content_moderation\ContentModerationState $state */
$state = $form_state
->get('state');
$is_required_state = isset($state) ? in_array($state
->id(), $this->workflowType
->getRequiredStates(), TRUE) : FALSE;
$form = [];
$form['published'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Published'),
'#description' => $this
->t('When content reaches this state it should be published.'),
'#default_value' => isset($state) ? $state
->isPublishedState() : FALSE,
'#disabled' => $is_required_state,
];
$form['default_revision'] = [
'#type' => 'checkbox',
'#title' => $this
->t('Default revision'),
'#description' => $this
->t('When content reaches this state it should be made the default revision; this is implied for published states.'),
'#default_value' => isset($state) ? $state
->isDefaultRevisionState() : FALSE,
'#disabled' => $is_required_state,
];
return $form;
}