In Yii 2. How to save several fields in another table in a field, such as a string separated by a comma

0

Maybe it seems weird what I want to do, but I explain to you

What I want is to save in a table, a string formed by a selection of records from another table, separated by a comma. That is, in the form that allows me to make the selection of the desired records from the other table, form the string separated by comma, and assign it to the form field, when saving the record, that chain formed with other data is saved of the form.

It may be that my idea is not the best, but I explain the problem better, so maybe they will indicate a better way to do it.

The problem is that each contractor has to create a contract, selecting customers from a list. The list shows all the clients of the province, but I wish that only the clients of the municipality that the contractor attends will be shown. If the contractor attended a single municipality, there would be no problems, but it happens that some contractors serve more than one municipality, and that's where I find it difficult to do so.

I would not like to modify the structure of the client table at all, just take advantage of the municipality's field, so that users do not have to modify each client again by adding data, that is, what they do is transparent to the user.

My idea is to create a field that contains the municipality or municipalities that the contractor serves, and after filtering I break down the chain separated by commas, and I create the where statement with that

    
asked by José A. Cáceres 19.07.2018 в 19:52
source

0 answers