0

enter image description here

I have a table like this.I want to fetch it inside the select tag but it's not working exactly what i am looking. I have register handlebar custom helper

  selectOption(status, options) {
    return options.fn(this).replace(new RegExp(`value=\"${status}\"`), '$&selected="selected"');
},

And inside the edit.hbs file

 <select name="getUser" multiple class="form-control selectpicker">
                    {{#selectOption message.user.id}}
                    {{#each user}}
                    <option value="{{this.id}}">{{this.fullName}}</option>
                    {{/each}}
                    {{/selectOption}}
                </select>

Problem is it's selecting only one user not multiple user on the edit page. how to set multiple select ?

  • I am having difficulty understanding. It looks like `message.user.id` has a single user id value. So what user id values do you expect to be selected? – 76484 Dec 28 '21 at 19:11
  • multiple user id @76484 – freelanceing mindset Dec 29 '21 at 09:03
  • If `message.user.id` is an array containing multiple user IDs, then I don't understand the regular expression in your `selectOption` helper. The regex clearly intends for the `status` parameter to be a single id value, but the helper is invoked with `message.user.id` as its `status` arg. If the value of `status` is an array, then I don't see how even one option is getting the `selected` attribute. – 76484 Dec 29 '21 at 12:22
  • @76484 i have solve the issue myself. yes there was a problem with `message.user.id` – freelanceing mindset Dec 29 '21 at 14:28
  • Then I would suggest you delete your question if you are not looking for further help. – 76484 Dec 29 '21 at 14:33

0 Answers0