I have looked around on the forum, but I have not found a current example. How can I set the error property from the server side and have it display on the client side?
$data = Editor::inst( $db, 'site','site_id' ) ->fields(
//add fields here
));
if ( isset($_POST['action']) && ($_POST['action'] === "create")) {
//check if we have exceeded the total amount of locations we can add.
if($we_have_exceeded === true){
//output error message to the server "error" property
// this should be consumed by the "error" property not the
//"fieldErrors" property.
} else {
//if there is no error proceed to process as usual.
$out = $data->process( $_POST )->data();
}
}
I see - thanks for the clarification. There is currently no method built in to the Editor class to set that option as there is no form level validation, just field level. However, you can simply set it directly:
Answers
Is this using the pre-built Editor libraries? This is the PHP documentation for validators.
You would do something like:
Allan
Thanks for your response, buit I should have been more specific. I wanted error message from the error property listed here:http://editor.datatables.net/manual/server#Server-to-client. for example in a create action :
I see - thanks for the clarification. There is currently no method built in to the Editor class to set that option as there is no form level validation, just field level. However, you can simply set it directly:
Obviously you'll need conditionals etc in then, but that is how it can be done.
Allan
Thanks again. All is well.