Example of using the mjoinMinCount validation

Example of using the mjoinMinCount validation

dermesdermes Posts: 3Questions: 1Answers: 0
edited May 2019 in DataTables 1.9

Hi!

I'm struggling to understand how to use the new Validate:mjoinMinCount() validation. Reading the manual this was my best guess of how to use it but this does not validate:

 ->join(
            Mjoin::inst( 'genres' )
                ->validator('genres[].id', Validate::mjoinMinCount(1))
                 ->link( 'contacts.id', 'contacts_genres.contact_id' )
                 ->link( 'genres.id', 'contacts_genres.genre_id' )
                 ->order( 'genres.genre asc' )
                 ->fields(
                     Field::inst( 'id' )
                          ->validator(Validate::required())
                          ->options( Options::inst()
                                            ->table( 'genres' )
                                            ->value( 'id' )
                                            ->label( 'genre' )
                      ),
                     Field::inst( 'genre' )
                 )
        )

Could you point me in the right direction?

Thanks!

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,436Questions: 1Answers: 10,049 Site admin

    That looks correct. Are you using the Editor 1.9.0 PHP libraries?

    Allan

  • dermesdermes Posts: 3Questions: 1Answers: 0

    Yes I'm using 1.9.0. On the 1.8 version i got an fatal error because of the missing methods.

    I get a list of other validations from the ajax response so i guess it's somewhere in the backend PHP code that something is incorrect.

    Example

    {
        "fieldErrors":
            [
                {
                    "name": "contacts.contact_name",
                    "status": "Input not valid"
                },
                {
                    "name": "contacts.email_address",
                    "status": "Input not valid"
                }
            ],
        "data": []
    }
    
  • allanallan Posts: 61,436Questions: 1Answers: 10,049 Site admin
    Answer ✓

    I'm up to speed now! I've committed the fix for this. I think I got myself slightly out of sync.

    You can use that change locally in 1.9.0 to get it running until we tag 1.9.1.

    Regards,
    Allan

  • dermesdermes Posts: 3Questions: 1Answers: 0

    Great, thanks allan!

This discussion has been closed.