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

how to save the list of child records with parent ID and input field in child

Hi All,

I have requirement to save the child records with parent id and with custom input type as text field in child.
Actually my reqirement is i need to show one form with topics,categories, tasks.Please find the below screen shot for referenceUser-added image
In the above form in need to save all the tasks in one child object with parent id and in the above image comments is the input text box.When i click on the save button the child records are going to save but what ever i have given in comments field that is not going to save it is taking only last comment, and save for all records.

Please find the below code for VF Page and Controller.


<apex:page controller="formOneController" showHeader="false" sidebar="false" docType="html-5.0">
  <apex:form >
  <div align="center"  draggable="false" >
        <apex:commandButton action="{!save}" value="save"/>&nbsp; &nbsp;
        <apex:commandButton value="Cancel" action="{!cancel}"/>
    <!--<apex:pageBlock >-->
        <apex:repeat value="{!technologyWrapperList}" var="T">
           <!-- <apex:column value="{!}"/>
            <apex:column value="{!T.member.Age__c}"/>
            <apex:column >-->
            <table style="width:100%" border="1" cellpadding="1" cellspacing="1">
                    <td colspan="2" style="background-color:RGB(0, 64, 255);color:White;font-weight:bold" height="20px"  text-align="top" width="100%"> Form : {!}</td>
            <apex:repeat value="{!T.catrgryList}" var="C">
            <table style="width:100%" border="1" cellpadding="1" cellspacing="0">
                <!--<apex:column value="{!C.Name__c}"/>-->
                <td colspan="0" style="background-color:RGB(179, 26, 255);color:white;font-weight:bold" height="20px"  text-align="top" width="25%">Category : {!C.Name__c}</td>
                <td colspan="0" style="background-color:RGB(179, 26, 255);color:white;font-weight:bold" height="20px"  text-align="top" width="25%">Description</td>
                <td colspan="0" style="background-color:RGB(179, 26, 255);color:white;font-weight:bold" height="20px"  text-align="top" width="23%">Check Box</td>
                <td colspan="0" style="background-color:RGB(179, 26, 255);color:white;font-weight:bold" height="20px"  text-align="top" width="15%">Comments</td>
                <td colspan="0" style="background-color:RGB(179, 26, 255);color:white;font-weight:bold" height="20px"  text-align="top" width="20%">Date</td>
                    <apex:repeat value="{!C.Topics__r}" var="P">
                        <!--<apex:column value="{!P.Name__c}"/>
                        <apex:column value="{!E.Serial_Number__c}"/>-->
                      <table style="width:100%" border="1" cellpadding="0" cellspacing="0"> 
                        <tr style="background-color:RGB(255, 255, 255);color:black;font-weight:normal"  text-align="top">
                        <td width="30%">{!P.Name__c}</td>   
                        <td width="28%">{!P.Description__c}</td>
                        <td width="27%"><apex:inputCheckbox /></td>
                        <td width="50%"><apex:input type="text" value="{!T.commt}" /> </td>
                        <!--<td width="50%"><apex:inputText value="{!datename}" size="10" id="demo" onfocus="DatePicker.pickDate(false, this , false);" /> </td>-->     
                        <td width ="50%"><apex:input type="date" value="{!dateValue}"/></td>


public with sharing class formOneController {

    public PageReference cancel() {
        return null;

    public String datename { get; set; }
    public String dateValue { get; set; }
    public list<site__c> siteList { get; set;}
    public site__c st { get; set;}
    //public string Comments { get; set;}
    public list<Category__c> listctg;
    //public list<Topic__c> listtpc;
     public string commt {get; set;}
     public list<Site__c> stchilds{get;set;}
    public list<site__c> newlistSite = new list<site__c>();
    public  PageReference save() {
        for(TechnologyWrapper awrapper : technologyWrapperList){
        listctg =[Select Name, Description__c, Name__c,Technology__c, (SELECT Name, Name__c, Description__c FROM Topics__r) FROM Category__c WHERE Technology__c = 'a082800000lbaHV'];
        for(Category__c cgry : listctg){
            for(Topics__c tpic : cgry.Topics__r){
                site__c objsite = new site__c();
                objsite.Technology_ID__c = 'a082800000lbaHV';
                objsite.Category_ID__c =;  
                objsite.Topics_ID__c =;
        /*stchilds = new list<Site__c>();
        for(TechnologyWrapper awrapper : technologyWrapperList){
          awrapper.commt =;
          awrapper.atd.LQ_Site_Initiation__c =;
        upsert newlistSite;
        return null;

   public List<Technology__c> technologyList { get; set; }
    public List<Category__c> categorytList { get; set; }
    public Map<Id, List<Category__c>> techIdCategorytListMap { get; set; }
    Set<Id> techIds = new Set<Id>();
    Map<Id, Technology__c> technologyMap = new Map<Id, Technology__c>();
    public List<TechnologyWrapper> technologyWrapperList { get; set; }

     public formOneController() {   
        dateValue = Date.Today().format();
        technologyList = [SELECT Name,Description__c,Name__c FROM Technology__c where id ='a082800000lbaHV'];
        techIdCategorytListMap = new Map<Id, List<Category__c>>();
        technologyWrapperList = new List<TechnologyWrapper>();
        if(technologyList.size() > 0) {
            for(Technology__c tngy : technologyList) {
                technologyMap.put(tngy.Id, tngy);
            categorytList = [Select Name, Description__c, Name__c,Technology__c, (SELECT Name, Name__c, Description__c FROM Topics__r) FROM Category__c WHERE Technology__c = 'a082800000lbaHV'];
            system.debug('Category List is ' + categorytList);
        if(categorytList.size() > 0) {
            for(Category__c ctg : categorytList) {
                    techIdCategorytListMap.put(ctg.Technology__c, new List<Category__c>());
            for(Id categoryId : techIdCategorytListMap.keySet()) {
                technologyWrapperList.add(new TechnologyWrapper(technologyMap.get(categoryId), techIdCategorytListMap.get(categoryId),commt));
    public class TechnologyWrapper {
        public Technology__c technology { get; set; }
        public List<Category__c> catrgryList { get; set; }
        public List<Topics__c> topicsList {get; set;}
        public string commt {get; set;}
        public boolean chekbx {get; set;}
        public date dt{get; set;}
        public TechnologyWrapper(Technology__c technology, List<Category__c> catrgryList,string commt) {
   = technology;
            this.catrgryList = catrgryList;
            this.commt = commt;
            chekbx = false;
            dt =;
    public class siteWrapper
        public Site__c lqst {get; set;}
        public String lqcmnts {get;  set;}
        public siteWrapper(Site__c sts,String cmnts)
            lqcmnts = cmnts;
            lqst = sts;

Please give some suggestions.