Validation Syntax
Validation Syntax
hamlet1964
Posts: 43Questions: 8Answers: 1
Can someone provide the correct syntax for the following:
Editor::inst( $db, 'Words', 'WCount' )
->fields(
Field::inst( 'Word' )
->validator( Validate::unique( new ValidateOptions::inst()
->message( 'Duplicate Entry') ),
Field::inst( 'Type'),
Field::inst( 'Phonetic' ),
Field::inst( 'Definition' )
)
->process( $_POST )
->json();
I'm trying to append an error message "Duplicate Entry" through the validator. No go. I get the following error:
DataTables warning: table id=words - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
If I delete the following text
new ValidateOptions::inst()
->message( 'Duplicate Entry')
all otherwise works properly.
Any help much appreciated.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You're missing the closing bracket for validator:
Still getting error after inserting the code, above.
Hi @hamlet1964 ,
Looking at the examples on this page it looks like you don't need the
new
beforeValidateOptions
.Hope that does the trick,
Cheers,
Colin
Thanks for the suggestion, Colin, however, that does not work, either.
should do it. If that isn't working for you, can you show me the response from the server (i.e. what the invalid JSON is) - likely it contains an error message.
My guess is that
ValidateOptions
isn't in youruse
statement.Allan
Allan - still not working - here's the response i received:
Here is the entire PHP file:
Perfect - thanks. As I suggested above you don't have a
ValidateOptions
definition in youruse
statement. Add that and I would expect it to work - e.g.:Allan
Yes, this now works! Thanks!!