function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pankaj IRTPankaj IRT 

What is difference between <apex: inputText/> and <apex: inputField/>. Plz explain with example.

Best Answer chosen by Pankaj IRT
Sai Ram ASai Ram A
Hi Pankaj

Input field by definition:
An HTML input element for a value that corresponds to a field on a Salesforce object. The < apex:inputField > component respects the attributes of the associated field, including whether the field is required or unique, and the user interface widget to display to get input from the user. For example, if the specified < apex:inputField >component is a date field, a calendar input widget is displayed.
When used in an < apex:pageBlockSection >, < apex:inputField > tags always display with their corresponding output label. - from component reference
In simple language - It's the field on the object and you can have any data type, which users can input . Example Picklist, look up, check box and / or multi select picklist etc......

Where as Input text by definition - 
An HTML input element of type text. Use this component to get user input for a controller method that does not correspond to a field on a Salesforce object.
This component does not use Salesforce styling. Also, since it does not correspond to a field, or any other data on an object, custom code is required to use the value the user inputs. - from component reference.
This is a field on the object which is of data type Text . Users can use to input only text using this field. 
You cannot use this for picklists , check boxes or any other data type.

Follow links to know more details
 https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_inputText.htm
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_inputField.htm

Hope this Helps!!
 

All Answers

Sai Ram ASai Ram A
Hi Pankaj

Input field by definition:
An HTML input element for a value that corresponds to a field on a Salesforce object. The < apex:inputField > component respects the attributes of the associated field, including whether the field is required or unique, and the user interface widget to display to get input from the user. For example, if the specified < apex:inputField >component is a date field, a calendar input widget is displayed.
When used in an < apex:pageBlockSection >, < apex:inputField > tags always display with their corresponding output label. - from component reference
In simple language - It's the field on the object and you can have any data type, which users can input . Example Picklist, look up, check box and / or multi select picklist etc......

Where as Input text by definition - 
An HTML input element of type text. Use this component to get user input for a controller method that does not correspond to a field on a Salesforce object.
This component does not use Salesforce styling. Also, since it does not correspond to a field, or any other data on an object, custom code is required to use the value the user inputs. - from component reference.
This is a field on the object which is of data type Text . Users can use to input only text using this field. 
You cannot use this for picklists , check boxes or any other data type.

Follow links to know more details
 https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_inputText.htm
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_inputField.htm

Hope this Helps!!
 
This was selected as the best answer
Pankaj IRTPankaj IRT
Thanks
Sai Ram ASai Ram A

P.S.  If my answer helps you to solve your problem please mark it as best answer. It will help other to find best answer.

Thank you
Sai