Hi all,
I would like to how i can make a field readonly while editing a record. But the field should be active while adding the record. Please help me in this,
Thanks,
Prajeesh
Hi all,
I would like to how i can make a field readonly while editing a record. But the field should be active while adding the record. Please help me in this,
Thanks,
Prajeesh
You need to create a custom view for the module (custom/modules/<ModuleName>/views/view.edit.php) containing something like that:
Obviously you need to replace the <ModuleName> and <FieldName> according to the module and field you want to customize.PHP Code:<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/MVC/View/views/view.edit.php');
class <ModuleName>ViewEdit extends ViewEdit {
function display() {
require_once('modules/Administration/QuickRepairAndRebuild.php');
$selected_actions = Array('clearTpls');
$modules = Array('<ModuleName>');
$RepairAndClear = new RepairAndClear();
$RepairAndClear->repairAndClearAll($selected_actions, $modules, $autoexecute = true, $show_output = false);
if($this->bean->id != '') {
foreach($this->ev->defs as $defs => $def_detail) {
foreach($def_detail as $panel => $panel_defs) {
if(is_array($panel_defs)){
foreach($panel_defs as $row => $row_defs) {
foreach($row_defs as $field => $field_defs) {
if(is_array($field_defs)) {
if($this->ev->defs[$defs][$panel][$row][$field]['name'] == '<FieldName>') {
$this->ev->defs[$defs][$panel][$row][$field]['type'] = 'readonly';
}
} else {
if($field_defs == '<FieldName>') {
$this->ev->defs[$defs][$panel][$row][$field] = array(
'name' => $field_defs,
'type' => 'readonly',
);
}
}
}
}
}
}
}
}
$this->ev->process();
parent::display();
}
}
?>
Regards
André Lopes
DevToolKit / Project of the Month - June 2009
Lampada Global Services- Open Source Solutions
Avenida Ipiranga, 318
Bloco B - CJ 1602
São Paulo, SP 01046-010
Brazil
Office: +55 11 3237-3110
Mobile: +55 11 7636-5859
e-mail: andre@lampadaglobal.com
Lampada Global delivers offshore software development and support services to customers around the world.
Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.
I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.
Hi,
I have used the following code for text field.
$modules = Array('<ModuleName>'); // Module Name - Bank
if ($this->ev->defs[$defs][$panel][$row][$field]['name'] == '<FieldName>') // Field Name = share_price
And add the Custome folder/ modulebuilder \packages \ <Module Name> \ view \ view.edit.php
The text filed is not readonly.
any other solutions.
Thanks
Bharat
Last edited by bharat12345; 2010-06-18 at 11:48 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks