Prevent save & publish if editable is empty


#1

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


#2

You can make the fields required?


#3

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


#4

Make a property mandatory in the Object Definition:
image


#5

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


#6

Oh sorry my bad… Good question :slight_smile: