2

If I wanted to rebuild a form in Drupal 7, conditional on the state of the form, I would do something like this:

if (isset($form_state['values']['foo'])) {
  $form['...
}

Now, $form_state is an object in Drupal 8. What would be the best equivalent?

2 Answers 2

1

Pretty much $form_state->getValue('foo');.

See the docs page for getValue.

1

I belive that the equivalent to isset() is

if ($form_state->hasValue('foo')) {
  ...
}

Your Answer

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

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