1

Under a specific Content Type with a ton of fields, my coworkers create nodes.

Most of the fields are required because we do not want any incomplete nodes.

However, since there are so many fields, is there a way for people to Save the node as a draft even without the required fields being filled out?

My first instinct was to use the Conditional Fields and have a Boolean called "Draft" that allows users to Check/Uncheck. Checking the box would cause each field to be Optional instead of Required.

However, since there are so many fields, each field would have to have conditions set to it individually.

That is my fallback solution, but is there a way I can accomplish this in a less tedious way?

  • First instinct would be to add a hook before validation happens to check if your "Draft" boolean field is enabled or not. If it is, modify the form data or wherever it indicates that the field is required so that it won't be required. – Joseph May 19 '17 at 18:08
  • 1
    It might be easier from the other side, remove required in the entity field setting and add a required #state to the field in a form alter hook '#states' => ['required' => [':input[name="draft"]' => ['checked' => FALSE]]] to switch the required state in the browser with the checkbox Draft – 4k4 May 19 '17 at 19:48

Your Answer

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

Browse other questions tagged or ask your own question.