Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / system / tests / modules / ajax_forms_test / src / Form / AjaxFormsTestImageButtonForm.php
1 <?php
2
3 namespace Drupal\ajax_forms_test\Form;
4
5 use Drupal\ajax_forms_test\Callbacks;
6 use Drupal\Core\Form\FormBase;
7 use Drupal\Core\Form\FormStateInterface;
8
9 /**
10  * Form builder: Builds a form that has image button with an ajax callback.
11  *
12  * @internal
13  */
14 class AjaxFormsTestImageButtonForm extends FormBase {
15
16   /**
17    * {@inheritdoc}
18    */
19   public function getFormId() {
20     return 'ajax_forms_test_image_button_form';
21   }
22
23   /**
24    * {@inheritdoc}
25    */
26   public function buildForm(array $form, FormStateInterface $form_state) {
27     $object = new Callbacks();
28     $form['image_button'] = [
29       '#type' => 'image_button',
30       '#name' => 'image_button',
31       '#src' => 'core/misc/icons/787878/cog.svg',
32       '#attributes' => ['alt' => $this->t('Edit')],
33       '#op' => 'edit',
34       '#ajax' => [
35         'callback' => [$object, 'imageButtonCallback'],
36       ],
37       '#suffix' => '<div id="ajax_image_button_result">Image button not pressed yet.</div>',
38     ];
39
40     return $form;
41   }
42
43   /**
44    * {@inheritdoc}
45    */
46   public function submitForm(array &$form, FormStateInterface $form_state) {
47     // No submit code needed.
48   }
49
50 }