salesforce
  1. salesforce-apex-inputtext-component

apex:inputText Component

The apex:inputText component is a Visualforce component in Salesforce that allows users to enter text in a form or page. This component renders an HTML input element of type text.

Syntax

The syntax for the apex:inputText component is as follows:

<apex:inputText value="{!field}" />

Example

The following example shows how to use the apex:inputText component to create a form field for entering a user's first name:

<apex:page>
  <apex:form >
    <apex:inputText value="{!contact.FirstName}" label="First Name"/>
    <apex:commandButton value="Save"/>
  </apex:form>
</apex:page>

Output

The above example will create a form field on a Visualforce page where users can enter their first name.

Explanation

The apex:inputText component creates an HTML input element of type text with the label "First Name". The value attribute binds the user input to a corresponding field in the controller. In this case, the field contact.FirstName is being updated with the user's input when the form is submitted.

Use

The apex:inputText component can be used to capture text input from users on a Visualforce page. It can be used to create simple form fields such as text boxes for user input.

Important Points

  • The apex:inputText component can be styled with CSS to match the look and feel of the rest of the page.
  • The value attribute is required and should be bound to a controller field or variable that holds the user's input.
  • The label attribute can be used to provide a label for the form field.

Summary

The apex:inputText component is a Visualforce component in Salesforce that allows users to enter text in a page or form. It creates an HTML input element of type text that can be used to capture user input. Its value attribute is bound to a corresponding field in the controller, and the label attribute can be used to provide a label for the input field. This component is useful for capturing text input from users in Visualforce pages.

Published on: