3

What is the best way to save node without the required field values?

It would be something like "save as unpublished" and the required validation is omitted, but I am not sure in which module I can find this functionality and how to set it up.

4
  • 1
    Sounds like core's Content Moderation and a custom submit handler maybe. Have you had a look at Content Moderation already and if it can be accomplished using it?
    – leymannx
    Aug 27 '20 at 8:36
  • 1
    This sounds like you are solving the wrong problem: Your fields are obviously not required, it is the publishing state that requires that certain fields are not null. Instead of making a hack-ish "maybe sometimes required" field, I'd write a custom form validation for the publish/status field.
    – Hudri
    Aug 27 '20 at 8:38
  • 1
    @NoSssweat I need to skip required fields on an edit form. Something like saving a draft before it can be published.
    – NeonBlank
    Aug 27 '20 at 8:48
  • @leymannx Yes, I took a quick look at it, but haven't succeeded yet to save, because it makes an ajax validation on the required fields when saving as a draft
    – NeonBlank
    Aug 27 '20 at 8:49
4

I finally solved this using the Require on Publish module. It offers an additional checkbox to require only when publishing the node.

This module allows fields to be required only when the piece of content is being published or is already published. This can be used when you have fields such as tags or SEO information on your piece of content that editors really don't need to fill in until the content is going live.

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.