public function ConfigureAction::buildForm in Views Bulk Operations (VBO) 4.0.x
Same name and namespace in other branches
- 8.3 src/Form/ConfigureAction.php \Drupal\views_bulk_operations\Form\ConfigureAction::buildForm()
- 8 src/Form/ConfigureAction.php \Drupal\views_bulk_operations\Form\ConfigureAction::buildForm()
- 8.2 src/Form/ConfigureAction.php \Drupal\views_bulk_operations\Form\ConfigureAction::buildForm()
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 FormInterface::buildForm
File
- src/
Form/ ConfigureAction.php, line 81
Class
- ConfigureAction
- Action configuration form.
Namespace
Drupal\views_bulk_operations\FormCode
public function buildForm(array $form, FormStateInterface $form_state, $view_id = NULL, $display_id = NULL) {
$form_data = $this
->getFormData($view_id, $display_id);
if (!isset($form_data['action_id'])) {
return [
'#markup' => $this
->t('No items selected. Go back and try again.'),
];
}
$form['#title'] = $this
->t('Configure "%action" action applied to the selection', [
'%action' => $form_data['action_label'],
]);
$form['list'] = $this
->getListRenderable($form_data);
// :D Make sure the submit button is at the bottom of the form
// and is editable from the action buildConfigurationForm method.
$form['actions']['#weight'] = 666;
$form['actions']['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Apply'),
'#submit' => [
[
$this,
'submitForm',
],
],
];
$this
->addCancelButton($form);
$action = $this->actionManager
->createInstance($form_data['action_id']);
if (method_exists($action, 'setContext')) {
$action
->setContext($form_data);
}
$form_state
->set('views_bulk_operations', $form_data);
$form = $action
->buildConfigurationForm($form, $form_state);
return $form;
}