Editor 1.6.0 PHP field options error
Editor 1.6.0 PHP field options error
Hi Allan,
Since ver. 1.6.0 all of my tables stopped working because I used field options for select2. I tried one of the examples from the datatables.net, but it gives me the same error. Did I miss something when I updated the version? What can be the solution for this error?
Fatal error: Uncaught Error: Call to undefined method DataTables\Editor\Field::_optsFn() in Editor\Field.php:564 Stack trace: #0 Editor\Editor.php(1002): DataTables\Editor\Field->optionsExec(Object(DataTables\Database)) #1 Editor\Editor.php(859): DataTables\Editor->_get(NULL, Array) #2 Editor\Editor.php(661): DataTables\Editor->_process(Array) #3 test.php(29): DataTables\Editor->process(Array) #4 {main} thrown in Editor\Field.php on line 564
// DataTables PHP library
require_once 'php/DataTables.php';
// Alias Editor classes so they are easy to use
use
DataTables\Editor,
DataTables\Editor\Field,
DataTables\Editor\Format,
DataTables\Editor\Join,
DataTables\Editor\Upload,
DataTables\Editor\Validate;
$editor=Editor::inst( $db, 'city', 'id' )
->field(
Field::inst( 'city.id' )->set(false)
->options( function () {
return array(
array( 'value' => '1', 'label' => 'Edinburgh' ),
array( 'value' => '2', 'label' => 'London' ),
array( 'value' => '3', 'label' => 'New York' ),
array( 'value' => '4', 'label' => 'San Francisco' )
);
} )
)
->process($_POST)
->data();
echo json_encode( $data);
} )
Thank you in advance
This question has an accepted answers - jump to answer
Answers
Doh - sorry. That's a bug in 1.6.0.
In the
Field.php
file you will find the line:Replace with:
And it will return to working.
I'll do a 1.6.1 release in the not too distant future with this fix.
Allan
Thanks, Allan. Now it works as it should.