+ Start a Discussion
SanjaySSanjayS 

Apex Input field.

The following code:
Customer Name<apex:inputField value="{!Customer__c.Name}"

Displays the input field below 'Customer Name' and not side by side as expected.
Any clue, Why it is doing that?

Best Answer chosen by Admin (Salesforce Developers) 
Jerun JoseJerun Jose

The apex:inputField tag eventually generates a table in the html which is why the inputfield elements are showing up in a new line. Changing the markup to

<apex:pageBlock >
	<apex:inputField label="Customer Name" value="{!Customer__c.Name__c}"/><br />
</apex:pageBlock>

 should do the trick

 

All Answers

Jerun JoseJerun Jose
Please post the complete code.
SanjaySSanjayS

Here is the code:

 

apex:page standardController="Customer__c">

<apex:form >  <!-- Begin Default Content REMOVE THIS -->

            Hello {!$User.FirstName}  <br />

                        <apex:pageBlock >Customer Name

                                    <apex:inputField value="{!Customer__c.Name__c}"/><br />

                        </apex:pageBlock>

            </apex:form>

 </apex:page>

Jerun JoseJerun Jose

The apex:inputField tag eventually generates a table in the html which is why the inputfield elements are showing up in a new line. Changing the markup to

<apex:pageBlock >
	<apex:inputField label="Customer Name" value="{!Customer__c.Name__c}"/><br />
</apex:pageBlock>

 should do the trick

 

This was selected as the best answer
SanjaySSanjayS

It works now. Thanks.

Rohan SureshkumarRohan Sureshkumar
This doesn't work for me for some reason:
 
<apex:inputField label="Customer Name" value="{!Customer__c.Name__c}"/>

There is no label displayed. Please help