Search code examples
metadataassetspimcorepimcore-v5

Pimcore Mandatory Metadata


is there an option to set some metadata from assets as a mandatory field ?

For data-objects you can create mandatory fields, but I need this option for the metadata of the asstes.


Solution

  • There is no such built-in option. But you can validate the data either in the frontend or the backend and disallow saving if not all required metadata is filled in.


    Backend validation

    You could for example throw a new Exception in a pre-update event listener:

    throw new \Pimcore\Model\Element\ValidationException("This is your custom error message", 1234);
    

    List of all Asset Events


    You could also check the data in the frontend as described here:

    Frontend validation