Goal: Print/dump $formState
values to debug
I am altering a form and the functionality works:
$form['elements']['location']['deparment']['#ajax'] = [
'callback' => 'myAjaxCallback',
'event' => 'change',
'progress' => [
'type' => 'throbber',
'message' => t('Verifying entry...'),
]
];
but what I want is to be able to print out $formState
in myAjaxCallback
function myAjaxCallback(array &$form, FormStateInterface $formState){
$response = new AjaxResponse();
print_r($formState); //I've tried, with memory_limit=-1 . it just hangs
dump($formState); //gives me File upload exceeds. This comes from issue with using dump in ajax
https://drupal.stackexchange.com/questions/250078/ajax-submission-leads-to-an-unrecoverable-error-occurred-the-uploaded-file-l
return $response
}
I have also read https://www.drupal.org/docs/drupal-apis/javascript-api/ajax-forms and tried their Debugging AJAX Callback Functions, which has:
$response = new AjaxResponse();
$debugOut = @Kint::dump($formState); //but this uses dump too, which gives me ajax errors
so dd($formState->getValues());
kind of works. This is what it shows me. So, as you can see, I can now see the variables. It's not the best, but readable.
whereas if I go to [website]/webform?ajax_form=1 , it's not even readable.
I am running out of ideas to be able to debug the variable $formState
.