I'm trying to change some forms from quickforms to angularjs.
In quickforms you do this: $this->addEntityRef('Location_province', ts('Select Province'), ['entity' => 'state_province',]);

How do I replicate this in Angularjs? This is what I thought I should do but probably a class or something in CRM to already do this: In js file:

provinces = crmApi('state_province', 'get', {
      country_id: 1039,
// do I process provinces to get to the values I want?
this.province = provinces
var ctrl = this

In the html template file I have:

<div crm-ui-field="{name: 'myForm.location_province', title: ts('Province'),}">
              crm-ui-select="{allowClear: true}"
              <option ng-repeat="option in $ctrl.province.values" value="{{option.name}}">

So its not working because the crmApi returns it in an array of multiple levels so is there a class to do this for me?

Thanks in advance!


Try below code

<div crm-ui-field="{name: 'myForm.location_province', title: ts('Province')}">
    name="myForm.location_province" crm-ui-id="myForm.location_province" 
     crm-entityref="{entity: 'state_province', api: {params: {country_id: 1039, is_active: 1, options:{sort:\'name\'}}}, select: {allowClear: true, minimumInputLength: 0, placeholder: ts(\'Select State\')}}"
  • Thanks! Exactly what I was looking for. Jun 4 at 12:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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