I'm creating an Invoice Module on SugarCRM Community Edition (version 6.5.16).
The trick I want to pull of is to make a field readonly based on the value of a checkbox named 'Sent'. So: If the invoice is sent the user is not able to edit the invoice anymore.
I know making a field readonly in editviewdefs can be done by setting type to readonly:
0 =>
array (
'name' => 'invoicenumber',
'label' => 'LBL_INVOICENUMBER',
'type' => 'readonly',
),
However, this field is now readonly regardless of the checkbox 'sent' is checked.
I tried editing the array with PHP in editviewdefs.php but this resulted in always closing the fields. That makes sense if editviewdefs.php is built once for all records.
Is there a way to do this with PHP or SugarCode (which is PHP of course)? The last resort I want to turn to is using javascript, but kind of want to avoid it since this is quite important functionality. One user accidentally turning off javascript could eventually be turning into quite a mess.
So, If you have any questions, please ask. For the sake of this OP I have included as little code as possible, but if you have questions regarding code feel free to ask!
Thanks a lot!