I add an admin grid using the below mentioned url. Now I add a multi-select field in the form by editing at App/Code/Webkul/Grid/Block/Adminhtml/Grid/AddRow.php file.It is visible fine. I use implode() function to convert the array into string and the value get stored at database as (1,3,5 ).But When I reopen the form by clicking on 'edit' option, form is loaded but in multiselect field only one value is selected. I need a help in this regard. Thank you.


1 Answer 1


You need to edit the following file:


Add the below code

$alloptions = array(
                    array('label' => 'ABC1', 'value' => 'ABC1'),
                    array('label' => 'ABC2', 'value' => 'ABC2'),
                    array('label' => 'ABC3', 'value' => 'ABC3'),
                    array('label' => 'ABC4', 'value' => 'ABC4'),
                    array('label' => 'ABC5', 'value' => 'ABC5'),
                    array('label' => 'ABC6', 'value' => 'ABC6'),

        'label' => __('Service Name'),
        'title' => __('Service Name'),
        'name' => 'name',
        'values' => $alloptions

You can change the options and field name according to your requirement.

Also you need to change the below file:


Add the below line:

$data['name'] = implode(',',$data['name']);

Just after the line:

$rowData = $this->gridFactory->create();

Like below:

$rowData = $this->gridFactory->create();
$data['name'] = implode(',',$data['name']);
if (isset($data['id'])) {

Here I am using field name as "name". You need to create a field name called "name" in the table as well.

No need to change any other files.

  • Welcome. Happy Coding. Aug 27, 2018 at 12:04

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.