$this->t("AJAX 'After': Click to put something after the div"), '#type' => 'submit', '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_after_callback', ], '#suffix' => '
Something can be inserted after this
', ]; // Shows the 'alert' command. $form['alert_command_example'] = [ '#value' => $this->t("AJAX 'Alert': Click to alert"), '#type' => 'submit', '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_alert_callback', ], ]; // Shows the 'append' command. $form['append_command_example'] = [ '#value' => $this->t("AJAX 'Append': Click to append something"), '#type' => 'submit', '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_append_callback', ], '#suffix' => '
Append inside this div
', ]; // Shows the 'before' command. $form['before_command_example'] = [ '#value' => $this->t("AJAX 'before': Click to put something before the div"), '#type' => 'submit', '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_before_callback', ], '#suffix' => '
Insert something before this.
', ]; // Shows the 'changed' command without asterisk. $form['changed_command_example'] = [ '#value' => $this->t("AJAX changed: Click to mark div changed."), '#type' => 'submit', '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_changed_callback', ], '#suffix' => '
This div can be marked as changed or not.
', ]; // Shows the 'changed' command adding the asterisk. $form['changed_command_asterisk_example'] = [ '#value' => $this->t("AJAX changed: Click to mark div changed with asterisk."), '#type' => 'submit', '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_changed_asterisk_callback', ], ]; // Shows the Ajax 'css' command. $form['css_command_example'] = [ '#value' => $this->t("Set the '#box' div to be blue."), '#type' => 'submit', '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_css_callback', ], '#suffix' => '
box
', ]; // Shows the Ajax 'data' command. But there is no use of this information, // as this would require a javascript client to use the data. $form['data_command_example'] = [ '#value' => $this->t("AJAX data command: Issue command."), '#type' => 'submit', '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_data_callback', ], '#suffix' => '
Data attached to this div.
', ]; // Shows the Ajax 'invoke' command. $form['invoke_command_example'] = [ '#value' => $this->t("AJAX invoke command: Invoke addClass() method."), '#type' => 'submit', '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_invoke_callback', ], '#suffix' => '
Original contents
', ]; // Shows the Ajax 'html' command. $form['html_command_example'] = [ '#value' => $this->t("AJAX html: Replace the HTML in a selector."), '#type' => 'submit', '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_html_callback', ], '#suffix' => '
Original contents
', ]; // Shows the Ajax 'insert' command. $form['insert_command_example'] = [ '#value' => $this->t("AJAX insert: Let client insert based on #ajax['method']."), '#type' => 'submit', '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_insert_callback', 'method' => 'prepend', ], '#suffix' => '
Original contents
', ]; // Shows the Ajax 'prepend' command. $form['prepend_command_example'] = [ '#value' => $this->t("AJAX 'prepend': Click to prepend something"), '#type' => 'submit', '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_prepend_callback', ], '#suffix' => '
Something will be prepended to this div.
', ]; // Shows the Ajax 'remove' command. $form['remove_command_example'] = [ '#value' => $this->t("AJAX 'remove': Click to remove text"), '#type' => 'submit', '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_remove_callback', ], '#suffix' => '
text to be removed
', ]; // Shows the Ajax 'restripe' command. $form['restripe_command_example'] = [ '#type' => 'submit', '#value' => $this->t("AJAX 'restripe' command"), '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_restripe_callback', ], '#suffix' => '
first row
second row
', ]; // Demonstrates the Ajax 'settings' command. The 'settings' command has // nothing visual to "show", but it can be tested via SimpleTest and via // Firebug. $form['settings_command_example'] = [ '#type' => 'submit', '#value' => $this->t("AJAX 'settings' command"), '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_settings_callback', ], ]; // Shows the Ajax 'add_css' command. $form['add_css_command_example'] = [ '#type' => 'submit', '#value' => $this->t("AJAX 'add_css' command"), '#ajax' => [ 'callback' => 'ajax_forms_test_advanced_commands_add_css_callback', ], ]; $form['submit'] = [ '#type' => 'submit', '#value' => $this->t('Submit'), ]; return $form; } /** * {@inheritdoc}. */ public function submitForm(array &$form, FormStateInterface $form_state) { } }