How do i get field type (e.g textfield, option, etc.) from $form_state
in below method.
public function validateForm(array &$form, FormStateInterface $form_state)
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityAs said before, it is in
$form['fieldname']['#type']
You don't need the state for this because it is not a state, it's static.
The render element types are defined using the #type property in the render array.
The only render element that the form state object (might [1]) reference directly is the main form element, via the getCompleteForm method.
[1] the form builder object sets the complete form parameter on the form state while building the form, so I'm the early stages it might not yet be set.
P.S.
The form state object does hold a reference the form object. Which means that in entity forms, you can get the entity and it's fields from the form state object.
$form
? It's available right there. – Beebee Jun 15 '16 at 14:25