You need to sign in to do that
Don't have an account?
InlineEditSupport with custom objects AND related objects
Hi,
I'm trying to create a custom detail view for a custom object and implement inline edits. However, the page is not only used to edit the custom object (Test_Parent__c) but also its related objects (Test_Child__c). Here is the controller:
public class TestController { public Test_Parent__c rep {get; set;} public List<Test_Child__c> recs {get; set;} public TestController() { String id = ApexPages.currentPage().getParameters().get('id'); rep = [select id, Test_Text__c from Test_Parent__c where Id = :id][0]; recs = [select id, Hours__c from Test_Child__c where Test_Parent__r.Id = :rep.Id]; } public PageReference save() { update rep; update recs; return null; } }
and here is the visualforce for this page:
<apex:page controller="TestController" > <apex:form > <apex:commandButton action="{!save}" id="saveButton" value="Save"/> <apex:inlineEditSupport> <table border="1" bordercolor="black"> <tr> <td>Parent Name:</td><td><apex:outputField value="{!rep.Test_Text__c}" ><apex:inlineEditSupport /> </apex:outputField></td> </tr> </table> <apex:repeat value="{!recs}" var="rec"> Child Hours: <apex:outputField value="{!rec.Hours__c}"><apex:inlineEditSupport /> </apex:outputField> </apex:repeat> </apex:inlineEditSupport> </apex:form> </apex:page>
Now, when I use the inline edit feature, the parent rep objects gets update and the child does not get updated. I played around with placing the inlineEditSupport tag inside the form and also inside the individual outputField records. I wasn't able to get this to work consistently to update both records at the same time. I would sometimes see that the child related record will get updated and most times it would not.
Any suggestions or ideas?
Your tags are mismatched, try using this cleaner markup:
Thanks Alex, I tried your suggestion but I had the same issue. I also tried using a single form element and that also didn't work. I'm thinking that this might be a bug.
Thanks Alex, Its working fine for me,
but not working for pageBlockTable control, can you suggest ?
The pageblock child record save is what I am having an issue with this also didnt work for me for that section. Works fine saving the parent but not the child. Any suggestions?