+ Start a Discussion
Bhola VishwakarmaBhola Vishwakarma 

Use of Input Field...

 

<!-- For this example to render properly, you must associate the Visualforce page 
with a valid account record in the URL. 
For example, if 001D000000IRt53 is the account ID, the resulting URL should be: 
https://Salesforce_instance/apex/myPage?id=001D000000IRt53
See the Visualforce Developer's Guide Quick Start Tutorial for more information. -->
         
<apex:page standardController="Account">
    <apex:form >
        <apex:pageBlock title="My Content" mode="edit">
            <apex:pageBlockButtons >
                <apex:commandButton action="{!save}" value="Save"/>
            </apex:pageBlockButtons>
            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:inputField value="{!account.name}"/>
                <apex:inputField value="{!account.type}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 This is a code for the standard Object but If I want to insert/reference any custom object then how can i do that ?

I tried this things as I putted {!CustomObjectName__c.CustomFieldName__c} as value of the input field...

Regards....

 

Best Answer chosen by Admin (Salesforce Developers) 
Sonali BhardwajSonali Bhardwaj
<!-- For this example to render properly, you must associate the Visualforce page 
with a valid account record in the URL.
For example, if 001D000000IRt53 is the account ID, the resulting URL should be:
https://Salesforce_instance/apex/myPage?id=001D000000IRt53
See the Visualforce Developer's Guide Quick Start Tutorial for more information.
Custom_Obj__c is the api name of your obj. Name and id are fields, you can put any field name of your custom object.
 -->

<apex:page standardController="Custom_obj__c">
<apex:form >
<apex:pageBlock title="My Content" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="My Content Section" columns="2">
<apex:inputField value="{!name}"/>
<apex:inputField value="{!id}"/>

</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>



All Answers

Sonali BhardwajSonali Bhardwaj
<!-- For this example to render properly, you must associate the Visualforce page 
with a valid account record in the URL.
For example, if 001D000000IRt53 is the account ID, the resulting URL should be:
https://Salesforce_instance/apex/myPage?id=001D000000IRt53
See the Visualforce Developer's Guide Quick Start Tutorial for more information.
Custom_Obj__c is the api name of your obj. Name and id are fields, you can put any field name of your custom object.
 -->

<apex:page standardController="Custom_obj__c">
<apex:form >
<apex:pageBlock title="My Content" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="My Content Section" columns="2">
<apex:inputField value="{!name}"/>
<apex:inputField value="{!id}"/>

</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>



This was selected as the best answer
Bhola VishwakarmaBhola Vishwakarma
<apex:page standardController="Custom_obj__c">
<apex:form >
<apex:pageBlock title="My Content" mode="edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="My Content Section" columns="2">
<apex:inputField value="{!Custom_obj__c.name__c}"/>
<apex:inputField value="{!
Custom_obj__c.id__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
So Field name will also gets appended by __c.
Thank you so much Sonali to help me...
Sonali BhardwajSonali Bhardwaj

Name and Id are standard fields. They exists for custom object as well. So they need to be given as Name and Id only.

 

For other fields you need to append __c. Basically you need to give field's API name here. You have to get your fields API name from fields view page.

Bhola VishwakarmaBhola Vishwakarma

Yaa I got the thing after viewing the standard Object...

But Sonali, Again I get stuck on Record Type....

Basically There are two record type are there in my object & each record type has certain field so how can i use them in VFPage.

I tried to use <apex:param> tag too but could not get the actual idea to use it...

So please guide for it also to me...

Regards...