The issue is that when I click on save, the data is not being saved... In the same object, I have a checkbox wich is being correctly saved, so I don't know what could be happening. I have next select:

<td><div class="slds-truncate">
          <lightning:select  aura:id="selectId" name="FormerReason"  label="Select a Former Reason:"  >
              <option  value="{!account.FormerReason}">{!account.Former_Reason__c}</option>
              <aura:iteration   items="{!v.options}" var="option">
                <option text="{!option.label}" value="{!option.value}" selected="{!option.selected}"></option>/>

being charged with this values:

loadOptions: function (component, event, helper) {
    var opts = [
        { value: "--None--", label: "--None--" },
        { value: "option1", label: "option1" },
        { value: "option2", label: "option2" }
     component.set("v.options", opts);

And a save button :

<td><button type="button" onclick="{!c.saveRecord}" >Save</button></td>

This is the save logic :

 saveRecord : function(component, event, helper) {
    var action = component.get("c.saveRelation");

        "account" : component.get("v.accounts")
    action.setCallback(this, function(data) {

and Apex recieving method:

public static boolean saveRelation (List<AccountContactRelation> account){
        update account;
        return true;
    catch(Exception e){
        return false;

This is a simple list that is not bound to any particular data. You need to bind it to the value it should represent:

      <lightning:select  aura:id="selectId" value="{!account.Former_Reason__c}"
         name="FormerReason"  label="Select a Former Reason:"  >

Without this binding, you won't get the result you expect. I also suspect that you do not need to actually use the iteration; you could have simply set options to the values you want to use, which is a lot easier to bind to dynamically.

  • Thanks for your help, it was exactly that, I just was needing some sleep to see this at myself . Ha. – CrispuSF Jan 26 '18 at 12:49

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.