0

I have a multiselect field in an angular form:

<div crm-ui-field="{name: 'subform.committees', title: ts('Secondary Committee')}">
  <div ng-controller="CommitteeCtrl">
    <select
      multiple="multiple"
      crm-ui-id="subform.committees"
      name="secondary_committee"
      crm-ui-select="{dropdownAutoWidth : true, allowClear: false, placeholder: ts('Choose Committee')}"
      ng-model="mailing.secondary_committee"
      ng-options="comm as comm.label for comm in comms track by comm.value"
    >
      <option />
    </select>
  </div>
</div>

I'm running into problems trying to figure out how to store the data and retrieve it so that the angular form loads the values properly. How does angular expect to see the data?

1
  • 1
    How about this one? Commented Feb 28, 2017 at 16:30

1 Answer 1

1

For MultiSelect ng-model is an Array, while Sending to Back-end you need to make [] as string, then it will fit into one column in DB:

var secondaryCommitteeStr = $scope.mailing.secondary_committee.join(',');

so while retrieving, you need to set your model data as selected entity's array, then angular will automatically populate selection entity's $scope.mailing.secondary_committee.

$scope.mailing.secondary_committee = data.split(',');// service data
Sign up to request clarification or add additional context in comments.

1 Comment

yes, on the retrieval step I wasn't converting back to an array, which was causing the issue.

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.