Using Chosen field type editor 1.4 options
Using Chosen field type editor 1.4 options
How do I use chosen for the field type when i am using field options in the Editor::inst
if i use select all options are displayed when i use chosen the select turns into the chosen plugin but displays no option.
editor = new $.fn.dataTable.Editor( {
ajax: "database/connections/attendance.php",
table: "#example",
fields: [ {
label: "Member:",
name: "members[].id",
type: "select"
}, {
label: "Guns:",
name: "guns[].id",
type: "chosen"
}
]
});
Editor::inst( $db, 'attendance' )
->fields(
Field::inst( 'id' )->validator( 'Validate::notEmpty' ),
Field::inst( 'member' ),
Field::inst( 'gun' ),
Field::inst( 'attendance.timestamp' )
)
//->leftJoin( 'members', 'members.id', '=', 'attendance.member' )
//->leftJoin( 'guns', 'guns.id', '=', 'attendance.gun' )
->join(
Join::inst( 'guns', 'array' )
->join('gun', 'id')
->fields(
Field::inst( 'id' )->validator( 'Validate::required' )->options( 'guns', 'id', 'name' ),
Field::inst( 'name' )
),
Join::inst( 'members', 'array' )
->join('member', 'id')
->fields(
Field::inst( 'id' )->validator( 'Validate::required' )->options( 'members', 'id', 'firstname' ),
Field::inst( 'firstname' ),
Field::inst( 'lastname' )
)
)
->process($_POST)
->json();
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Interesting one - the
options
method doesn't actually work with anything but the built inselect
,checkbox
andradio
field types. I think I should update it to work with anything hat has anupdate()
method. I will do so and a new beta should be available on Monday with this future.Allan
Actually - it turns out that the
options
method does work with any field that defines anupdate()
method, but thechosen
plug-in didn't. I've just updated and republished the plug-in which you can use with 1.4 now.Also, this will work with the latest chosen release (1.3.0 at the time of writing).
Regards,
Allan
Thank you, its working great.