I'm trying to get a field value on form save but I can't do it for the life of me. dpm($form_state->getValue('field_tckn')) gave me null and so did $form_state->getValues()). dpm($form_state) produced the below output, but I can't seem to get the value even if I can find the field. Can you help?

dpm output

  • What field type is fiel_tckn? What's in the array where the screenshot ends?
    – leymannx
    Oct 31 at 17:26
  • It would help to see the part of the buildForm method where that field is defined. What's the output of dpm($form_state->getValues())? What you're looking at in the screenshot is the input, not the values. Is this a clean drupal install or could there be additional custom code that might interfere with the form processing?
    – berliner
    Nov 5 at 23:57
  • I didn't implement buildForm. I used .yml files.
    – Kartagis
    Nov 10 at 7:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.