public function DeleteUpdateForm::buildForm in Scheduled Publish 8.3
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 ConfirmFormBase::buildForm
File
- src/
Form/ DeleteUpdateForm.php, line 81 - Contains \Drupal\scheduled_publish\Form\DeleteUpdateForm.
Class
Namespace
Drupal\scheduled_publish\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $entity = NULL, $field_delta = NULL) {
if (!isset($entity) || !isset($field_delta)) {
$form['message'] = [
'#theme_wrappers' => [
'container',
],
'#markup' => $this
->t('A valid entity and field delta must be provided.'),
];
return $form;
}
$fields = $this
->getScheduledFields($entity
->getEntityTypeId(), $entity
->bundle());
$field = reset($fields);
$states = $entity
->get($field)
->getValue();
if (!isset($states[$field_delta])) {
$form['message'] = [
'#theme_wrappers' => [
'container',
],
'#markup' => $this
->t('This status update does not exist.'),
];
return $form;
}
$form['message'] = [
'#theme_wrappers' => [
'container',
],
'#markup' => $this
->t('If this state deletion invalidates any existing transitions those will be deleted as well.'),
];
// Save data into form_state and class variables.
$form_state
->set([
'scheduled_publish',
'entity',
], $entity);
$form_state
->set([
'scheduled_publish',
'field',
], $field);
$form_state
->set([
'scheduled_publish',
'field_delta',
], $field_delta);
$this->entity = $entity;
$this->field = $field;
$this->field_delta = $field_delta;
return parent::buildForm($form, $form_state);
}