Code snippet on changing the size of Text Areas

sugarcrmdevelopers —  February 12, 2008 — 2 Comments

A community member asked in the forums yesterday how to customize the height and width of a text area in the Edit View layout. With the new MVC UI framework in Sugar 5.0, you no longer edit the Xtemplate html file directly like you did in 4.5 but rather modify the editviewdefs.php file for the form you want to change.

Here is an example where you create a custom field, place it on the Edit View and Detail View forms and then manually edit the resulting editviewdefs.php to change the size of the Text Area. This example also shows you how to use the maxlength parameter to limit the amount of text that can be added to the text area. For you HTML junkies out there, you know that this is a custom JS function found in the Sugar UI framework that limits the text entered as the standard HTML textarea tag doesn’t have such a parameter.

 

Example:
1) Create a new custom TextArea field in the Opportunities module using Sugar Studio.
2) Add the custom field to the EditView and the DetailView layouts by adding a new row to the bottom of the layouts and then dropping the field onto the screen. NOTE: Be sure to remove the second filler field from the new row you added so that the new custom field will span across the two columns.
3) Save and deploy the changes to both layouts.
4) Now open in a text editor the new file custom/modules/Opportunities/metadata/editviewdefs.php.
5) Find the Comments field definition and modify it to include the new displayParams parameter below:

array (
'name' => 'comments_c',
'label' => 'LBL_COMMENTS',
'displayParams'=>array('rows'=>20, 'cols'=>80, 'maxlength'=>350),
),

2 responses to Code snippet on changing the size of Text Areas

  1. 

    This does not work for me.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s