Guest User

Untitled

a guest
Nov 21st, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. $form['captcha'] = array(
  2. '#type' => 'captcha',
  3. '#captcha_type' => 'recaptcha/reCAPTCHA',
  4. '#required' => TRUE,
  5. );
  6.  
  7. $form['actions']['submit'] = [
  8. '#name' =>'submit',
  9. '#type' => 'submit',
  10. '#value' => $this->t('Submit'),
  11. '#ajax' => [
  12. 'callback' => '::ajaxSubmitForm',
  13. 'event' => 'click',
  14. ],
  15. ];
  16.  
  17. public function ajaxSubmitForm(array &$form, FormStateInterface $form_state) {
  18.  
  19. $response = new AjaxResponse();
  20.  
  21. if ($form_state->hasAnyErrors()) {
  22. $response->addCommand(new ReplaceCommand('#form-modal-form', $form));
  23. }
  24.  
  25. return $response;
  26. }
Add Comment
Please, Sign In to add comment