How to add custom validate rule in backend form relation manager

328 Views Asked by At

have a backend form with 2 differents relation manager.

For one of those, i need to add specific validation rule so im looking for the right place to put the validation code.

My main model is a Course session so i have a Sessions controller

The related model is participant

functionnally, i need to check if it remains place in course

  • if yes, the participant can be create then refresh the page
  • if not, i just want to display an error message without register the new participant

here my relation behavior config, don't know if its usefull, ask for more if needs

# ===================================
#  Relation Behavior Config
# ===================================

participants:
    label: participant
    view:
        list: $/author/courses/models/participant/columns.yaml
        toolbarButtons: create|delete
    manage:
        form: $/author/courses/models/participant/fields.yaml
        recordsPerPage: 10
    emptyMessage: 'Aucun participant pour cette session'
sessionDates:
    label: Date
    view:
        list: $/author/courses/models/sessiondate/columns.yaml
        toolbarButtons: create|delete
    manage:
        form: $/author/courses/models/sessiondate/fields.yaml
        recordsPerPage: 10
    emptyMessage: 'Aucune date pour cette session'
1

There are 1 best solutions below

0
On

Can't you set the rules on participants model?