How i can add multiple input field dynamically and how we can send multiple input field data to controller. Example:
<apex:page controller="controllermethod">
<apex:form >
<apex:pageBlock mode="edit"><br/><br/>
<div class="row">
<apex:outputLabel styleClass="label" value="Project Name " />
<apex:inputField styleClass="field" value="{!newproj.Name}"/>
</div>
<div class="row">
<apex:outputLabel styleClass="label" value="Start Date "/>
<apex:inputField styleClass="field" value="{!newproj.Start_Date__c}"/>
</div>
<div class="row">
<apex:outputLabel styleClass="label" value="Module "/>
<apex:inputField styleClass="field" value="{!module.Name}"/>
</div>
<div class="row">
<apex:outputLabel styleClass="label" value="Vendor "/>
<apex:inputField styleClass="field" value="{!module.Vendor__c}"/>
</div>
<div class="row">
<apex:outputLabel styleClass="label" value="Module "/>
<apex:inputField styleClass="field" value="{!module.Name}"/>
</div>
<div class="row">
<apex:outputLabel styleClass="label" value="Vendor "/>
<apex:inputField styleClass="field" value="{!module.Vendor__c}"/>
</div>
<apex:commandButton value="Save" action="{!savecreatenew}"/>
<apex:commandButton value="Cancel" action="{!closePopup}" />
</apex:pageBlock>
</apex:form>
</apex:page>
My controller is:-
public class controllermethod
{
public Project__c newproj{get;set;}
public Module__c module{get;set;}
public controllermethod()
{
newproj = new Project__c();
module=new Module__c();
}
public PageReference savecreatenew() {
insert newproj;
module.Project__c = String.valueOf(newproj.get('Id'));
insert module;
module.clear();
newproj = new Project__c();
return null;
}
}
This is working fine but i want to add multiple modules for single project i.e i want to provide one add button for users to add multiple modules and vendors for that project.