Editor One to Many Joins, Select2

Editor One to Many Joins, Select2

vincmeistervincmeister Posts: 136Questions: 36Answers: 4
edited July 2016 in Editor

Hello Allan,

Is it possible to use select2 on one to many join?
My tables (as link table) are
- act_log_head
- link_log_customer
- master_customer

I want to populate customer name from master_customer to act_log_head using select2
My code below is not working with select2, but with checkbox like this example is good

->join(
            Mjoin::inst( 'master_customer' )
                ->link( 'act_log_head.act_log_id', 'link_log_customer.act_log_id' )
                ->link( 'master_customer.customer_code', 'link_log_customer.customer_code' )
                //->order( 'master_customer.name asc' )
                ->fields(
                    Field::inst( 'customer_code' )
                        ->options( 'master_customer', 'customer_code', 'customer_name' )
                        ->validator( 'Validate::notEmpty' ),
                    Field::inst( 'customer_name' )
                )
        )
{
label: "Customer:",
name: "master_customer[].customer_code",
//type: "checkbox",
type: "select2",
opts: {
multiple: "true"
}
}

Error:
Option 'multiple' is not allowed for Select2 when attached to a <select> element.

Please advise, about the checkbox alternative, because the option are too much. thank you
Danny

This question has accepted answers - jump to:

Answers

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin

    Is it possible to use select2 on one to many join?

    Yes, it should be. I've used:

                {
                    label: "id:",
                    name: "list[].id",
                    type: 'select2',
                    opts: { multiple: true },
                    options: [ 1, 2, 3, 4, 5, 6 ]
                }
    

    before and it worked okay.

    Allan

  • vincmeistervincmeister Posts: 136Questions: 36Answers: 4
    edited July 2016

    Hi Allan,

    What is the 1,2,3,4,5,6 on options? I think if i'm using select options from MySQL, the options can leave blank

    Is it works with select2 Version: 3.5.4 ?
    I still got error Option 'multiple' is not allowed for Select2 when attached to a <select> element.

    Please advise, thank you

  • allanallan Posts: 61,431Questions: 1Answers: 10,048 Site admin
    Answer ✓

    What is the 1,2,3,4,5,6 on options? I think if i'm using select options from MySQL, the options can leave blank

    Correct - that was just for my test to make sure it was populated correctly. You would use whatever data source you have for your options.

    Is it works with select2 Version: 3.5.4 ?

    Ah no - probably not. This is with Select2 4.0.1.

    Allan

  • vincmeistervincmeister Posts: 136Questions: 36Answers: 4

    Hi Allan,

    I'm changing to Select2 4.0.3 , the select function not working for the customer field , it's appear as text. this using Mjoin as on my question (left pic)

    On my other select2, status field, using LEFT JOIN, it works. But the options appear behind the modal form. z-index problem maybe? (right pic)

    Please assist

  • vincmeistervincmeister Posts: 136Questions: 36Answers: 4
    edited July 2016 Answer ✓

    Hi Allan,

    after i added this style, it works as expected

            .select2-dropdown{
            z-index: 3051;}
    

    Many thanks,
    Danny

This discussion has been closed.