AjaxFormsTestLazyLoadForm.php in Zircon Profile 8.0
File
core/modules/system/tests/modules/ajax_forms_test/src/Form/AjaxFormsTestLazyLoadForm.php
View source
<?php
namespace Drupal\ajax_forms_test\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
class AjaxFormsTestLazyLoadForm extends FormBase {
public function getFormId() {
return 'ajax_forms_test_lazy_load_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form['#attached']['drupalSettings']['test'] = 'currentPathUpdate';
$form['add_files'] = array(
'#title' => $this
->t('Add files'),
'#type' => 'checkbox',
'#default_value' => FALSE,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => $this
->t('Submit'),
'#ajax' => array(
'wrapper' => 'ajax-forms-test-lazy-load-ajax-wrapper',
'callback' => 'ajax_forms_test_lazy_load_form_ajax',
),
'#prefix' => '<div id="ajax-forms-test-lazy-load-ajax-wrapper"></div>',
);
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state
->setRebuild();
}
}