You are here

public function ActionForm::submitForm in Filebrowser 3.x

Same name and namespace in other branches
  1. 8.2 src/Form/ActionForm.php \Drupal\filebrowser\Form\ActionForm::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/ActionForm.php, line 152

Class

ActionForm
Class ActionForm.

Namespace

Drupal\filebrowser\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {

  // No items are selected and we have to display an error. We have to do
  // it here for the ajax enabled buttons. For the normal submit buttons
  // this will be handled by the form validation method.
  // \Drupal::logger('filebrowser')->notice('SUBMIT FORM');
  if ($this->error) {

    // set the error in the slide down window
    $form_state
      ->setRedirect('filebrowser.no_items_error');
  }
  else {
    $op = $form_state
      ->getTriggeringElement()['#return_value'];
    $route_param = $this->common
      ->routeParam($this->nid, $this->relativeFid);
    $route_param['method'] = 'ajax';
    $route_param['op'] = $op;
    $route_param['fids'] = $this->fids;
    $route = 'filebrowser.action';

    // NB: links are not submitted and do not pass through this submit function
    $form_state
      ->setRedirect($route, $route_param);
  }
}