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
okaylah52okaylah52 

How can I set the rows and columns in apex inputField bound to a comment (multiple line text field)?

I am writing a Visualforce page using apex tags.

I have an inputField in a pageBlockSection (1 column).
How can I configure the inputField dimension which is bound to a text field which allows multiple lines (e.g. Task.Description) in my controller?

For example: in HTML code, I can write something like "<textarea rows="20" columns="80">". Can I do the same using apex:inputField? If not and I have to de-couple the label and the input field (using inputTextArea), then how can I bind the value to my variable in my controller? Do I need some kind of Javascript or Ajax to do the job?

Thanks.
Best Answer chosen by Admin (Salesforce Developers) 
CTU007CTU007

Hi, I used the style and changed the inputField layout, but still, for a text field, when user enters data, it won't change rows (word wrap), all input data are in one row....

 

Is there a way to let it change rows as per the width of the style? 

All Answers

hisrinuhisrinu
Hi,

If you use inputfield, it will automatically bind to that variable. you need to do like this.

<apex:input value="{!objectname.fieldname}"/>


Thanks
Srini
okaylah52okaylah52
I found the solution based on other articles.

Solution is to use style something like...
Code:
<apex:page controller="MyController">
<style>
.dim_a {width:400px; height:150px;}
.dim_b {width:200px; height:60px;}
</style> ...
<apex:inputField value="{!myTask.location}" styleClass="dim_b"/>
<apex:inputField value="{!myTask.Description}" styleClass="dim_a"/> ... </apex:page>

 

CTU007CTU007

Hi, I used the style and changed the inputField layout, but still, for a text field, when user enters data, it won't change rows (word wrap), all input data are in one row....

 

Is there a way to let it change rows as per the width of the style? 

This was selected as the best answer