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

How to work with ActiveRecord models? #303

Open
kwazaro opened this issue Jul 18, 2019 · 5 comments
Open

How to work with ActiveRecord models? #303

kwazaro opened this issue Jul 18, 2019 · 5 comments
Milestone

Comments

@kwazaro
Copy link

kwazaro commented Jul 18, 2019

How to automatically save data to database and read it for widget using ActiveRecord models? No information or examples provided, only examples with \yii\base\Model. Maybe, some Trait should be created, to convert data to JSON and back to PHP array? It is not good idea to edit controllers. I think data conversion should be done by this extension automatically, because without this using of extension is not convenient.

@kwazaro
Copy link
Author

kwazaro commented Jul 19, 2019

Should I use the JSON column database type for fields? Also, I noticed, that 'sortable' has some strange behavior when using JSON database column type: it doesn't change row indexes after sorting, so after saving the result has no effect (the order is based on row numeric "keys", they don't changing after sorting).

@unclead
Copy link
Owner

unclead commented Jul 20, 2019

did you read the article https://github.com/unclead/yii2-multiple-input/wiki/Basic-scenario-of-usage ?
I don't agree that the widget has to be responsible for server-side processing, because it doesn't know anything about your business logic.

Originally it was created only to provide a simple way to manage similar data such as email/phones without the necessity to reinvent the wheel each time.
But the widget has evolved a lot since its first release and it contains many features now.

If you want to implement a trait or a yii behavior to simplify processing data on server-side, PR is always welcome

@kwazaro
Copy link
Author

kwazaro commented Jul 21, 2019

And what about JSON type in database column? Sortable not working in this case, because of fixed array indexes. JSON type is preferable for such data.

@unclead
Copy link
Owner

unclead commented Jan 8, 2021

@kwazaro still relevant or I can close the issue?

@kwazaro
Copy link
Author

kwazaro commented Jan 8, 2021

You should mention in description that this component doesn't support sorting for JSON fields. There is no solution for now.

@unclead unclead added this to the 3.0 milestone Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants