1

I have created a custom webform handler by extending WebformHandlerBase. And I can get the data from the WebformSubmission. However, I can only get the machine name of the field. I would like to get field label. For instance, I get "fname" machine name as the key, but I want to get "First Name" or what ever label is set in the admin for this webform.

Does anyone know how I might get to that information from a webform submission entity?

1 Answer 1

0

I assume that you pass $form, and $form_state into your custom handler function. You can always access your webform field "label" via $form variable.

Try kint() or dd() $form['elements'] on specific form and go into depth to find your field, then you can easily get $form['elements']['my_field_name']['#title'] etc.

1
  • 1
    Well, I'm not adding a custom submit handler like I would have in D7. I'm talking about when I extend the WebformHandlerBase class. I'm inside that, and I'm having trouble figuring out how to get to the label. I can get to the data and keys, but not the field label.
    – xpersonas
    Feb 25, 2020 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.