How to open modal on form button click with data from callback?

by serj   Last Updated February 19, 2019 16:07 PM

I have a form button with ajax callback:

'button_ajax' => array(
          '#type' => 'button',
          '#value' => t('Add short name'),
          '#attributes' => [
            'class' => ['btn', 'btn-default', 'add-short-name'],
            'data-toggle' => 'modal',
            'data-target' => '#addShortName',
          ],
          '#theme' => 'buget_modal_add_short_name',
          '#ajax' => [
            'callback' => 'buget_ajax_get_short_names',
          ],
      ),

Also I have defined theme "buget_modal_add_short_name" in the modal file and "buget_ajax_get_short_names" function that is currentrly empty. What should the callback do in order to render a list of items in this modal that is defined in the theme on 'button_ajax' click?



Related Questions




Modal Form Submission

Updated November 15, 2018 23:07 PM

Modal does not handle errors on login

Updated April 29, 2019 15:07 PM