0

Is there a way to add a hidden field in the edit view of a custom module in Sugar Pro 6 and then assign a value to that field and use that value in the before_save logic hook by obtainig it via REQUEST variable for example $_REQUEST['hiddenfieldname'].

Any help will be appreciated!

Sheikh Rahat Ali
  • 1,293
  • 8
  • 37
  • 61

2 Answers2

3

You could use the "hidden" entry in the editviewdefs metadata like that :

    $viewdefs ['ModuleName'] =
array (
  'EditView' =>
  array (
    'templateMeta' =>
    array (
      'maxColumns' => '2',
      'form' =>
      array (
        'hidden' =>
        array (
          0 => '<input type="hidden" name="MyFiedlName" id="MyFiedlName" value="MyFieldValue">',
        ),
        'buttons' =>
        array (
  • After adding this code i can not access the hidden field on the edit page by document.getElementById('MyFiedlName').value in javascript as well as in the before_save logic hook connected to this edit page in logic hook. I am accessing the value of hidden field by the $_REQUEST['MyFiedlName'] object. – Sheikh Rahat Ali Jul 26 '12 at 10:28
  • Did you make a quick repair and rebuild after modify the editviewdefs? Also where do you push your Javascript code? WIth AjaxUi you should to use some methods to launch JS at the correct time like it's describe here : http://developers.sugarcrm.com/wordpress/2011/09/30/improving-sugarcrm-client-side-performance-the-sugarcrm-ajaxui/ – Cédric Mourizard Aug 30 '12 at 05:40
0

try this on your input item definition: value="{$smarty.request.MyFiedlName}"