/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$form['leasing_options'] = [
'#type' => 'details',
'#title' => $this->t('Mileage / Duration'),
'#open' => TRUE,
'#ajax' => [
'callback' => '::ajaxModalCallback',
'event' => 'click',
'progress' => [
'type' => 'throbber',
],
],
];
}
/**
* AJAX callback for the Mileage/Duration table modal.
*
* @param array $form
* The form array.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The form state object.
*
* @return \Drupal\Core\Ajax\AjaxResponse
* The AJAX response.
*/
public function ajaxModalCallback(array &$form, FormStateInterface $form_state) {
$response = new AjaxResponse();
$settings = array(
'dialogClass' => 'adopt-modal',
'width' => '700',
);
// see all commands here: Drupal\Core\Ajax
$response->addCommand(new OpenModalDialogCommand($title, $content, $settings));
return $response;
}