protected function ScheduledPublishWidget::buildEditForm in Scheduled Publish 8.3
Builds the entry edit form.
1 call to ScheduledPublishWidget::buildEditForm()
- ScheduledPublishWidget::addEntries in src/
Plugin/ Field/ FieldWidget/ ScheduledPublishWidget.php - Adds existing entries to the widget.
File
- src/
Plugin/ Field/ FieldWidget/ ScheduledPublishWidget.php, line 250
Class
- ScheduledPublishWidget
- Plugin implementation of the 'scheduled_publish_widget' widget.
Namespace
Drupal\scheduled_publish\Plugin\Field\FieldWidgetCode
protected function buildEditForm(&$form, $wrapper, $field_name, $entry, FormStateInterface $form_state) {
$form['#element_validate'] = [
[
get_class($this),
'validateElement',
],
];
$form['moderation_state'] = [
'#type' => 'select',
'#title' => $this
->t('Moderation state change'),
'#default_value' => $entry['state'],
'#options' => $entry['state_options'],
];
$form['value'] = [
'#type' => 'datetime',
'#title' => $this
->t('Scheduled date'),
'#default_value' => new DrupalDateTime($entry['date'], ScheduledPublish::STORAGE_TIMEZONE),
'#date_increment' => 1,
'#date_timezone' => date_default_timezone_get(),
'#element_validate' => [],
];
$form['actions'] = [
'#type' => 'container',
'#weight' => 10,
];
$form['actions']['sp_edit_confirm'] = [
'#type' => 'button',
'#value' => $this
->t('Save'),
'#name' => 'sp-' . $field_name . '-edit-confirm-' . $entry['delta'],
'#limit_validation_errors' => [
$form['#parents'],
],
'#ajax' => [
'callback' => [
get_called_class(),
'getElement',
],
'wrapper' => $wrapper,
],
'#sp_id' => $field_name,
'#sp_row_delta' => $entry['delta'],
];
$form['actions']['sp_edit_cancel'] = [
'#type' => 'button',
'#value' => $this
->t('Cancel'),
'#name' => 'sp-' . $field_name . '-edit-cancel-' . $entry['delta'],
'#limit_validation_errors' => [],
'#ajax' => [
'callback' => [
get_called_class(),
'getElement',
],
'wrapper' => $wrapper,
],
'#sp_id' => $field_name,
'#sp_row_delta' => $entry['delta'],
];
}