0

I'm using D8's core contact form, I have added some custom fields and I want to change one of custom fields' settings config programatically.

I have tried this

\Drupal::service('entity_field.manager')->getFieldDefinitions('contact_form')

but I get error:

LogicException: Getting the base fields is not supported for entity type Contact form. in Drupal\Core\Entity\EntityFieldManager->buildBaseFieldDefinitions() (line 204 of core/lib/Drupal/Core/Entity/EntityFieldManager.php).

Is there any way to get list of fields and update their configs and settings?

1

Try this one:

$fields = \Drupal::service('entity_field.manager')->getFieldDefinitions('contact_message', 'personal');

You can change personal to your contact form bundle.

Your Answer

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

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