You need to sign in to do that
Don't have an account?

Creating related records in visualforce page
Hi All,
I have two objects Event__C and Registrant__C .on Registrant object we hav a lookup field event link pointing to event object .
Now i have created a VF page on event object which i am displaying on site.
in this page the first part shows details of events using output field and the second part shows registrant object fields so that a site user can register for the event .But i am not able to do it properly .Please help me .
Getting error "
Error: Invalid field Registrant__r for SObject Event__c |
"
Heres the code
<apex:page standardController="event__c" sidebar="false" showHeader="false" extensions="Registerbutton">
<table width="90%" align="center">
<tr>
<td>
<apex:form >
<apex:pageBlock title="Welcome For Registration" >
<apex:pageBlockSection title="Event Details">
<apex:Outputfield value="{!Event__c.Name}" />
</apex:pageBlockSection>
<apex:pageBlockSection title="Guest Information" columns="2">
<apex:inputField value="{!Event__c.Registrant__r.First_Name__c}" />
<apex:inputField value="{!Event__c.Registrant__r.Last_Name__c}" />
<apex:inputField value="{!Event__c.Registrant__r.Company__c}" />
<apex:inputField value="{!Event__c.Registrant__r.Email__c}" />
<apex:inputField value="{!Event__c.Registrant__r.Phone__c}" />
<apex:inputField value="{!Event__c.Registrant__r.Address__c}" />
</apex:pageBlockSection>
<apex:pageBlockButtons location="bottom" >
<apex:commandButton action="{!Register}" value="Register " />
</apex:pageBlockButtons>
</apex:pageBlock>
<apex:image value="{!$Resource.elephant1}" width="100%" height="50%" />
</apex:form>
</td>
</tr>
</table>
</apex:page>
Hi,
Since you are trying to display the related list, you have to use that in a datatable or pageblocktable
for iteration i think
Try to use the same in datatable
Thanks
Arvind
I am still getting the error
Can you please check the Registrant object name once.
Because I am able to save the code which I posted without any error. But when I give some other name for
the child object, I am getting the same error as you are getting
My object names are : A, B
I am using the following code:
Here A is parent and B is child
Thanks for your reply ...it works now and displays child records..
But my requirement is to create child records ....not display the existing one ...
How can i achieve this ...please help me ...
If you have two objects Event__C and Registrant__C and Registrant__c is the child, you need to use pulural object for the related one. Try using this way.
Event__c.Registrants__r