+ Start a Discussion
Chamil MadusankaChamil Madusanka 

Need a help for Visualforce form

How can I create a form in like this way. This is in a Contact standard page. In here Title and first name are two fields. But they are apear in single line. How can I create this in visualforce?

Best Answer chosen by Admin (Salesforce Developers) 
shra1_devshra1_dev

Hi Chamil,

 

I cannot see your screen shot, but  from your post I think you want to merge the Salutation and First Name.

 

Try this to merge the fields...

 

Under PageBlock Section Add this code..

 

 

<apex:PageBlockSectionItem >
            <apex:outputLabel >
                        First Name
            </apex:outputLabel>
                    
            <apex:outputPanel >
                        <apex:inputField value="{!contact.salutation}"/>
                        <apex:inputField value="{!contact.firstname}"/>
            </apex:outputPanel>
</apex:PageBlockSectionItem><br/>

 

 

Hope this helps...

 

 

Regards,

Shravan

All Answers

minkeshminkesh

Hello chamil,

                        what you want to do ? do you want to create this field in single line ?

Chamil MadusankaChamil Madusanka

Hi,

 

Yes, I want to create two fields in single line. For a example,

 

Title and the name in single line. Title will be a pick list and name will be a textbox. But the lable must be "Name"

 

I think you can  see a screen shot.

 

minkeshminkesh

Hello chamil,

                        If you want to create field in single line you can use pageblocksection. in that column attribute is there so give column="2".

Chamil MadusankaChamil Madusanka

But pageblocksection haven't column attribute. Here is my code snippet. Here I got two columns for fields. But Title and the firstname fields must be apear as the screen shot?

 

 

<apex:page standardController="Contact">
  <apex:form >
      <apex:sectionHeader title="Contact"/>
      <apex:pageBlock title="Contact Details">
          <apex:pageblockButtons >
              <apex:commandButton value="Edit" id="editContact"/>
              <apex:commandButton value="Delete" id="deleteContact"/>
              <apex:commandButton value="Clone" id="cloneContact"/>
          </apex:pageblockButtons>
          
         
         
          <apex:pageblockSection >
          
       
              <apex:inputField value="{!Contact.Salutation}" id="salutationInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.FirstName}" id="fnameInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.LastName}" id="lnameInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.Title}" id="titleInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.Department}" id="departmentInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.Birthdate}" id="birthdateInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.LeadSource}" id="leadSourceInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.Phone}" id="phoneInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.HomePhone}" id="homePhoneInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.MobilePhone}" id="mobilePhoneInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.OtherPhone}" id="otherPhoneInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.Fax}" id="faxInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.Email}" id="emailInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.AssistantName}" id="assistantNameInputFields"></apex:inputField>
              <apex:inputField value="{!Contact.AssistantPhone}" id="assistantPhoneInputFields"></apex:inputField>
              
              
          </apex:pageblockSection>
          
          
      </apex:pageBlock>
      
      
  </apex:form>
</apex:page>

 

 

shra1_devshra1_dev

Hi Chamil,

 

I cannot see your screen shot, but  from your post I think you want to merge the Salutation and First Name.

 

Try this to merge the fields...

 

Under PageBlock Section Add this code..

 

 

<apex:PageBlockSectionItem >
            <apex:outputLabel >
                        First Name
            </apex:outputLabel>
                    
            <apex:outputPanel >
                        <apex:inputField value="{!contact.salutation}"/>
                        <apex:inputField value="{!contact.firstname}"/>
            </apex:outputPanel>
</apex:PageBlockSectionItem><br/>

 

 

Hope this helps...

 

 

Regards,

Shravan

This was selected as the best answer
Chamil MadusankaChamil Madusanka

Hi Shravan,

 

Thank you very much. It helps to continue my works.

 

--

Chamil Madusanka