function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Will M SmithWill M Smith 

Binding behaviour on lightning components with ui:inputText/Checkbox components

I'm currently building a lightning component for a community builder portal. The whole series of components is reasonably complex but nothing extreme (it's a wizard).

To make things easier I'm using a wrapper class with several objects and sub objects in. Again, it's more than just a simple wrapper class but nothing too complex.

When I bind a field using ui:inputText or ui:inputCheckbox, for example, it appears to be binding (in some cases, not all) to a non-existent field one level up the wrapper class object structure.

Looking at the screenshot below you can see 'Patient_Information_Checked__c'. This field sits on the appointment object. However, as you can see the value is being bound one level up (line 3 on the image) so when I try to save it doesn't submit the correct value...

User-added image

Here is a shortened version of my component code:
 
<aura:iteration items="{!v.treatments}" var="treatmentWrapper">
    <div>
        <aura:if isTrue="{!treatmentWrapper.isSelected == true}">
            <ui:inputCheckbox aura:id="checkbox-patientCheckReferrer" value="{!treatmentWrapper.appointment.Patient_Information_Checked__c}" class="checkbox"/>
        </aura:if>
    </div>
</aura:iteration>

Am I approaching this incorrectly? Or is there a known issue with using the ui:input series of fields and binding? I also tried using the lightning:input and I experience the same issue.

My workaround at the moment is duplicate the field as a String or Boolean in the outer most layer of my wrapper then copy in the value to the correct field on save... This isn't ideal for many obvious reasons.