0

I have a list builder widget in yii which looks something like this.

I want to save all the selected values in the right column to my database.How can I pass the selected values to controller? Please help in this regard

2 Answers 2

1

I have figured this out for myself.

The widget already includes by default the saving code too.

Here is the link for saving list widget to database.

Sign up to request clarification or add additional context in comments.

Comments

0

If you are getting an array after submitting the form then use serialize() and save. (It will convert the array to a formatted string).

$model->attribute=serialize($_POST['modelname']['attribute'])
-----
$model->save();

and use unserialize() while fetching the data.

Or

You can use foreach to traverse through the array and store each selected.

1 Comment

When I submit my form, it is displaying all the elements on the left hand side instead of only selected values on right side.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.