Validation using PHP library
Validation using PHP library
I have this array
Array
(
[action] => create
[data] => Array
(
[0] => Array
(
[employee_age] => 8
[employee_name] => Patrik
[employee_salary] => 1233
[lat] => 55.3324
[lng] => 25.32342
)
)
)
Can I use Datables Editor php validation library in this case :
$data['employee_age'] = $_POST['data'][0]["employee_age"];
Below function do not work:
Field::inst("employee_age")
->validator(Validate::minNum( 16 ));
Not sure if it helps but this is debuger information: ifezor
This discussion has been closed.
Answers
Can you show me your full PHP code for Editor please?
Thanks,
Allan
Hi,
This is Javascript file with cutted out some unnecessary info
This is PHP file with cutted out some unnecessary info
We managed to make validator to work like this, but maybe it is easer way
I don't actually see the
minNum
validator being applied anywhere there. Am I missing it?Allan
We have tried to use validation like in this example and it didin't worked.
I don't see your
Field
instance being assigned to anything. Its creating aField
instance, but nothing ever calls it.You need to attach it to an
Editor
instance using theEditor->field()
method.Allan
Which PHP library you are using for the validation? There are a lot of them out there you know?
Allan. If you have possibility, can you explain how "You need to attach it to an Editor instance using the Editor->field() method." to make it function according sample code which is above. I just need example how to validate using native Editor tool if salary is number or not empty and after that I can figure out why and how it works...
This manual page here should help - it's explaining how to define fields.
Colin
I'm not very experienced in PHP so maybe i miss something, but issue is that i want(I need) to use custom SQL, in my simple example above to insert data I use
I do not use
Therefore i do not know how to skip $editor = Editor::inst( $db, 'employee' );... part and still be able to use validation.
You cannot I'm afraid. If you want to write your own query to enter information in the database, you'd also need your own validation.
That said, I don't see anything in your custom SQL query that PHP / Postgres wouldn't sort out themselves. The Editor libraries should be able to construct that insert for you.
Have you tried using them, and if so, did you run into any issues?
Thanks,
Allan