0

I have a List (text) field in a content type that will determine the importance of the content whether it is Major or Minor and that field is set to be required. I need to force content editors to make that selection each time they edit a content page. Is there a way to clear the data from that field upon edit event?

Note: I'm on Drupal 9.2.18

4
  • 3
    If I got it right, HOOK_form_alter should be ok, then set the field[YOURFIELD]['default_value'] = NULL; Apr 27, 2022 at 6:20
  • 2
    Remember to specify which version of Drupal you're using.
    – Lambic
    Apr 27, 2022 at 17:11
  • 1
    @HodbaKhalaf. The hook_form_alter worked only the NULL value was rejected so I replaced it ' ' and that solved the issue. Thanks! Apr 28, 2022 at 19:28
  • @Lambic Sorry for not specifying Drupal version, it's 9.2.x. Apr 28, 2022 at 19:30

1 Answer 1

1

HOOK_form_alter should be ok, then empty the field default value.

$form[YOURFIELD]['default_value'] = '';

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.