Sugar Developer Blog

Code snippet on changing the size of Text Areas

12 Feb, 2008
Posted By: Clint

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),
),

Leave a Reply

Have feedback for us? Drop us a line.
Terms & Conditions | Privacy | Trademark Info | Contact Info | FAQs | SugarCRM Inc.© 2004 - 2008 All rights reserved.