2

I am having a field, Final_Step__c which is of data type Text Area.

I am showing it in VF page:

but, due to maximum length issue of <apex:textarea> i wanted to use html <textarea> component with maxlength attribute.

so, any idea how to use <textarea> component in VF page?

2
  • are you referring to apex:inputTextArea? I don't know of an apex:textarea component per the VF doc.
    – cropredy
    Apr 18, 2014 at 23:25
  • <textarea> is a HTML component Apr 19, 2014 at 0:36

1 Answer 1

2

VF component apex:inputTextArea generates textArea as underlying HTML. To support the maxlength attribute, you use HTML-5 pass-through attributes as documented here.

Here is a simple example (no controller extension required):

<apex:page standardController="Foo__c" doctype="html-5.0">
 <apex:form >
   <apex:commandButton value="save" action="{!save}"/>
   <apex:inputTextArea value="{!Foo__c.bar__c}" html-maxlength="10" rows="2" cols="10"/>
 </apex:form>
</apex:page>

The above assumes field bar__c is of type textArea as per your problem statement

Notes

  1. apex:page requires adding attribute doctype="html-5.0"
  2. You 'pass through' the VF attribute html-maxlength to the underlying textarea HTML-5 maxlength attribute

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .