public function EntitySubqueueForm::form in Entityqueue 8
Gets the actual form array to be built.
Overrides ContentEntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- src/
Form/ EntitySubqueueForm.php, line 70
Class
- EntitySubqueueForm
- Form controller for the entity subqueue edit forms.
Namespace
Drupal\entityqueue\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['#title'] = $this
->t('Edit subqueue %label', [
'%label' => $this->entity
->label(),
]);
// Since the form has ajax buttons, the $wrapper_id will change each time
// one of those buttons is clicked. Therefore the whole form has to be
// replaced, otherwise the buttons will have the old $wrapper_id and will
// only work on the first click.
if ($form_state
->has('subqueue_form_wrapper_id')) {
$wrapper_id = $form_state
->get('subqueue_form_wrapper_id');
}
else {
$wrapper_id = Html::getUniqueId($this
->getFormId() . '-wrapper');
}
$form_state
->set('subqueue_form_wrapper_id', $wrapper_id);
$form['#prefix'] = '<div id="' . $wrapper_id . '">';
$form['#suffix'] = '</div>';
// @todo Use the 'Machine name' field widget when
// https://www.drupal.org/node/2685749 is committed.
$element_info = $this->elementInfo
->getInfo('machine_name');
$form['name'] = [
'#type' => 'machine_name',
'#default_value' => $this->entity
->id(),
'#source_field' => 'title',
'#process' => array_merge([
[
get_class($this),
'processMachineNameSource',
],
], $element_info['#process']),
'#machine_name' => [
'exists' => '\\Drupal\\entityqueue\\Entity\\EntitySubqueue::load',
],
'#disabled' => !$this->entity
->isNew(),
'#weight' => -5,
'#access' => !$this->entity
->getQueue()
->getHandlerPlugin()
->hasAutomatedSubqueues(),
];
return $form;
}