PHP Datatable\Editor doesn't give a value
PHP Datatable\Editor doesn't give a value
microshop
Posts: 11Questions: 4Answers: 1
When using Editor, the user edit a row. I want to know some field values submitted by the user, in server side.
In PHP, I use this method:
->on('preEdit', function ( $editor, $values ) {
$val = $editor->field('myField')->getValue();
})
$val returns empty.
And $editor->field('myField') returns this:
DataTables\Editor\Field Object
(
[_dbField:DataTables\Editor\Field:private] => myField
[_get:DataTables\Editor\Field:private] => 1
[_getFormatter:DataTables\Editor\Field:private] =>
[_getFormatterOpts:DataTables\Editor\Field:private] =>
[_getValue:DataTables\Editor\Field:private] =>
[_opts:DataTables\Editor\Field:private] =>
[_optsFn:DataTables\Editor\Field:private] =>
[_name:DataTables\Editor\Field:private] => myField
[_set:DataTables\Editor\Field:private] => both
[_setFormatter:DataTables\Editor\Field:private] =>
[_setFormatterOpts:DataTables\Editor\Field:private] =>
[_setValue:DataTables\Editor\Field:private] =>
[_validator:DataTables\Editor\Field:private] => Array
(
)
[_upload:DataTables\Editor\Field:private] =>
[_xss:DataTables\Editor\Field:private] =>
[_xssFormat:DataTables\Editor\Field:private] => 1
)
So, I don't know how to know the value of a field submitted by the user in the editor.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I solved this.
First, this is bad:
The function accepts ($editor, $id, $values), not ($editor, $values). (...I copied the function from preCreate).
And then, with $values, I've accesed to the array and I've get the values that needed.
Thanks for posting back - great to hear you've got it working.
Allan