Drupal 8.9 and paragraph 8.x-1.11
My issue is that Ajax breaks when altering the #validate form. This is an issue for any form! It may have to do with my ajax, but here is my setup.
I have a paragraph type:
contact_information
- field_phone_number (telephone from core)
- field_type_of_phone (text_plain)
I have a custom module. In this custom module I am creating a form_alter on /user/register
I have:
function telephone_alter_form_user_register_form_alter(&$form, $form_state, $form_id ){
//$form['#validate'] = array(); //commenting this in or out doesn't help
$form['#validate'][] = 'telephone_alter_test_validate';
//$form['field_phone']['widget']['#element_validate'][] = 'telephone_alter_test_validate';
}
function telephone_alter_test_validate($form, &$form_state) {
echo "hi"; //prints hi, but ajax breaks
}
The validation works, prints out debugging. However, when I try to add another paragraph element, it does nothing. This is for any form. I have tried this on other forms like adding a basic page and trying to call an alter function!
the Ajax error displayed is:
[{"command":"insert","method":"prepend","selector":null,"data":"\u003Cdiv data-drupal-messages\u003E\n \u003Cdiv class=\u0022messages__wrapper\u0022\u003E\n \u003Cdiv class=\u0022alert alert-danger alert-dismissible\u0022 role=\u0022alert\u0022 aria-label=\u0022Error message\u0022\u003E\n \u003Cbutton type=\u0022button\u0022 role=\u0022button\u0022 class=\u0022close\u0022 data-dismiss=\u0022alert\u0022 aria-label=\u0022Close\u0022\u003E\u003Cspan aria-hidden=\u0022true\u0022\u003E\u0026times;\u003C\/span\u003E\u003C\/button\u003E\n \u003Ch2 class=\u0022sr-only\u0022\u003EError message\u003C\/h2\u003E\n \u003Cp\u003EAn unrecoverable error occurred. The uploaded file likely exceeded the maximum file size (40 MB) that this server supports.\u003C\/p\u003E\n \u003C\/div\u003E\n \u003C\/div\u003E\n\u003C\/div\u003E\n","settings":null}]
The Ajax error is key, because if I create an alter form for any other page, I still get the error.
Any help is great! Thank you! I can provide more info if needed