Trying to get a design that is configurable as either one or two columns. This uses a recordEditForm
which make it challenging as the button MUST be between the recordEditForm
tags.
current code:
<div class="{!if(v.twoColumnLayout,'slds-size_1-of-2','slds-size_1-of-1')}">
<lightning:recordEditForm ....>
<lightning:messages/>
<aura:iteration items="..." var="f">
<lightning:inputField fieldName="{!f}" id="{!f}"/>
</aura:iteration>
<lightning:button aura:id="submit-button" class="slds-m-top_small slds-align_absolute-center" type="submit" label="Click" variant="brand"/>
</lightning:recordEditForm>
</div>
<aura:if isTrue="{!v.twoColumnLayout}">
<div class="slds-size_1-of-2">
<c:AnotherComponent ...../>
</div>
</aura:if>
The issue here is the Lightning button
In single column mode everything is fine. But in two column mode the button is stuck within the confines of the slds-size_1-of-1
and I need it to be centered across both columns
Issue
I can get it working in the UI by putting the AnotherComponent
within the recordEditForm
as the below code shows BUT the recordEditForm
breaks due to the lightning:inputs
and a recordData
form on the second component and throw an error about a field on the second component not being focusable....they do not play nice nested together
<lightning:recordEditForm ....>
<div class="{!if(v.twoColumnLayout,'slds-size_1-of-2','slds-size_1-of-1')}">
<lightning:messages/>
<aura:iteration items="..." var="f">
<lightning:inputField fieldName="{!f}" id="{!f}"/>
</aura:iteration>
<aura:if isTrue="{!v.twoColumnLayout}">
<div class="slds-size_1-of-2">
<c:AnotherComponent ...../>
</div>
</aura:if>
<lightning:button aura:id="submit-button" class="slds-m-top_small slds-align_absolute-center" type="submit" label="Click" variant="brand"/>
</div>
</lightning:recordEditForm>
So the only way the components work is in the first code example which gives me this
but I cannot seem to get the button to cover both columns due to it being constrained within the slds-size_1-of-2
parent div
Any Ideas including CSS hacks?
Current workaround
I have added margin-left: calc(100% - 30px);
to the element and in the current container it does put it ...about... where I want it but seems a bit fragile to me
cmp.find('recordEditFormId').submit()
onsubmit
method to be called. only theonsuccess
andonerror
are called. In my case I need to do some preprocessing in theonsubmit
:(margin-left: calc(100% - 30px)
as posted above, on my screen at least.....maybe that is the best I can get...I am not a CSS wiz so any ideas at a more forgiving css that is responsive would be great. I do agree CSS may be the only way to go here