Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checkbox Relation selection problem #1187

Closed
dev7ch opened this issue Jan 26, 2017 · 15 comments
Closed

Checkbox Relation selection problem #1187

dev7ch opened this issue Jan 26, 2017 · 15 comments
Assignees
Labels
Milestone

Comments

@dev7ch
Copy link
Contributor

dev7ch commented Jan 26, 2017

public function injectors()
    {
        return [
            'publications' => new ActiveQueryCheckboxInjector([
                'query' => Publication::find()->select(['title', 'subtitle']),
            ]),
        ];
    }

This Example above is referrs to a NgRest model.

If you select one checkbox in the admin backend, all checkboxes getting selected.

Any ideas?

@nadar
Copy link
Contributor

nadar commented Jan 26, 2017

I am unable to reproduce this problem, my test config:

'test' => new ActiveQueryCheckboxInjector([
    'query' => NavItem::find(),
]),

I could select the items from the nav item table, and print them in the block view.

Whats does your model look like?

@dev7ch
Copy link
Contributor Author

dev7ch commented Jan 26, 2017

public function ngRestConfig($config)
    {
        $config->list->field('title', 'Titel')->text();
        $config->list->field('subtitle', 'Untertitel')->text();

        $config->update->copyFrom('create');

        $config->delete = true;

        return $config;
    }

@nadar
Copy link
Contributor

nadar commented Jan 26, 2017

The ngRestConfig is not related to the ActiveQueryCheckboxInjector.

@nadar
Copy link
Contributor

nadar commented Jan 26, 2017

What happens if you choosen another query? Is this If you select one checkbox in the admin backend, all checkboxes getting selected. a problem from the UI? What will be display in the frontend view? Are selectiones stored in the database?

@dev7ch
Copy link
Contributor Author

dev7ch commented Jan 26, 2017

If i use 'query' => NavItem::find() or 'query' => Publication::find() all works fine.

@dev7ch
Copy link
Contributor Author

dev7ch commented Jan 26, 2017

It looks like the select() option of the lablefield causes this error.

'query' => Publication::find()->select(['title', 'subtitle']

@nadar
Copy link
Contributor

nadar commented Jan 26, 2017

But then only those fields will be displayed? But the selection wont work anymore? What if you choose a not i18n casted field in the select? I tryed the select() as well and it worked fine, hmm.

my test case:

'test' => new ActiveQueryCheckboxInjector([
    'query' => NavItem::find()->select(['title']),
]),

@dev7ch
Copy link
Contributor Author

dev7ch commented Jan 26, 2017

ok maybe i am miss understanding the use of selection ...
So selection is for field restriction only ?

In my case select() was used to limit the labels from the checkboxes but not the output in the view

@nadar
Copy link
Contributor

nadar commented Jan 26, 2017

Currently it does affect both of them (the select checkbox and the models extra data in the view file). Maybe it should only affect the select checkbox in the administration view, but this is not related to your problem - cause you where "unable to select a checkbox, cause it selected all of them then"?

@dev7ch
Copy link
Contributor Author

dev7ch commented Jan 26, 2017

bildschirmfoto 2017-01-26 um 15 23 31

Without select()

@dev7ch
Copy link
Contributor Author

dev7ch commented Jan 26, 2017

bildschirmfoto 2017-01-26 um 15 26 55

with select() and i18n field ( only one checkbox was clicked )

@nadar
Copy link
Contributor

nadar commented Jan 26, 2017

so the problems appears only when select is used with an i18n casted field?

@dev7ch
Copy link
Contributor Author

dev7ch commented Jan 26, 2017

probably yes

@nadar nadar added this to the 1.0.0 milestone Jan 26, 2017
@nadar nadar self-assigned this Jan 26, 2017
@nadar nadar closed this as completed in bb63b67 Jan 27, 2017
@nadar
Copy link
Contributor

nadar commented Jan 27, 2017

@dev7ch I just added new option label in order to provide custom labels:

see: https://github.com/luyadev/luya/blob/master/modules/cms/src/injectors/ActiveQueryCheckboxInjector.php#L47-L59

Don't forget to remove the select() in your active query. Please let me know if i18n fields are displayed correctly.

@dev7ch
Copy link
Contributor Author

dev7ch commented Jan 31, 2017

Yes, the new implementation works great with i18n fields. Cheers & Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants