Using Chosen field type editor 1.4 options

Using Chosen field type editor 1.4 options

mbrennandmbrennand Posts: 34Questions: 4Answers: 0
edited December 2014 in Editor

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

Answers

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    Interesting one - the options method doesn't actually work with anything but the built in select, checkbox and radio field types. I think I should update it to work with anything hat has an update() method. I will do so and a new beta should be available on Monday with this future.

    Allan

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin
    edited December 2014 Answer ✓

    Actually - it turns out that the options method does work with any field that defines an update() method, but the chosen 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

  • mbrennandmbrennand Posts: 34Questions: 4Answers: 0

    Thank you, its working great.

This discussion has been closed.