Prevent save & publish if editable is empty

Hi,

I have a document type with two editables (date and input). I want to prevent saving (and publishing) the document if any of these editables are empty.

How can I achieve it? I tried to hook into “preSaveDocument” in a plugin. It’s fired, but I cannot stop the event propagation. Throwing one of pimcore.error.*Exception leads to an error “Uncaught exception” and the page freezes.

Do you have any idea?

BR,
Alex

You can make the fields required?

How can I do this? I didn’t find it in the documentation.

Make a property mandatory in the Object Definition:
image

I’m not talking about objects. I’m talking about document where I can use ‘$this->date()’ or ‘$this->input()’ in *.html.php

Oh sorry my bad… Good question :slight_smile:

Hi,

Did you solve this issue? I am stuck in the same problem.

How can I achieve that?

Thanks in advance.

No, my solution was to prefill the date editable with the current date by default. Has been good enough for my use case.

You can achieve that only for types:

  • Input
  • WYSIWYG
  • Textarea
  • Numeric

like:

{{ pimcore_input(“headerLine”, {…, ‘required’: true}) }}