如何 - 按钮更改下拉值?

时间:2016-06-15 17:49:38

标签: php sugarcrm

我想问一下如何让一个按钮改变一个字段的值。

1 如上图所示,“下拉状态”应更改为“未付款”状态。付款。'人们告诉我糖社区要改变元数据。我尝试过,但是我无法调用该字段并更改其值。 我所知道的是,我的状态'字段是LBL_Quote_Stage。

请问任何可能的解决方案? 此外,这是我的模块' UA_Quotes'

的元数据代码
<?php  
$module_name = 'UA_Quotes';  
$viewdefs [$module_name] =   
array (  
  'DetailView' =>   
  array (  
    'templateMeta' =>   
     array (  
       'form' =>   
            array (  
                 'closeFormBeforeCustomButtons' => true,  
                 'buttons' =>   
                     array (  
                        0 => 'EDIT',  
                        1 => 'DELETE',  
                        2 =>   
                           array (  
            'customCode' => '<input id="MonthlyQuote" title="Monthly Quote" class="button" type="button"   
                    name="Quote Payment" value="Quote Payment" onclick="alert(\'How to change status :(\')">',  
      ),  
    ),  
    'footerTpl' => 'modules/UA_Quotes/tpls/DetailViewFooter.tpl',  
  ),  
  'maxColumns' => '2',  
  'widths' =>   
  array (  
    0 =>   
    array (  
      'label' => '10',  
      'field' => '30',  
    ),  
    1 =>   
    array (  
      'label' => '10',  
      'field' => '30',  
    ),  
  ),  
  'useTabs' => false,  
  'tabDefs' =>   
  array (  
    'LBL_EDITVIEW_PANEL2' =>   
    array (  
      'newTab' => false,  
      'panelDefault' => 'expanded',  
    ),  
  ),  
),  
'panels' =>   
array (  
  'lbl_editview_panel2' =>   
  array (  
    0 =>   
    array (  
      0 => 'name',  
      1 =>   
      array (  
        'name' => 'ua_contracts_ua_quotes_1_name',  
      ),  
    ),  
    1 =>   
    array (  
      0 =>   
      array (  
        'name' => 'monthlystart_c',  
        'label' => 'LBL_MONTHLYSTART',  
      ),  
      1 =>   
      array (  
        'name' => 'quote_stage',  
        'studio' => 'visible',  
        'label' => 'LBL_QUOTE_STAGE',  
      ),  
    ),  
    2 =>   
    array (  
      0 =>   
      array (  
        'name' => 'monthlydeadline_c',  
        'label' => 'LBL_MONTHLYDEADLINE',  
      ),  
    ),  
  ),  
),  
  ),  
);  
?>  

我正在使用sugarCE 6.5,谢谢大家! :(

1 个答案:

答案 0 :(得分:0)

点击“报价付款”按钮,您必须拨打电话。

  1. 创建一个新的javascript文件,并通过元数据将其包含在您的模块中直接在view.detail.php文件中写一个js functiona OR 调用你的函数打电话给&#39; customCode&#39; =&gt; onclick事件
  2. 你的js代码看起来像
  3. var record = $("#record").val();  // value of record which you can see in
    var fdata = { 'record':record };
    $.ajax({
        url: "ajaxFiles/addPayment.php?&fdata="+fdata+"",
        type: 'POST',
        data: fdata,
        dataType: 'html',
        async: false,
        error: function(resp){},
        success: function(resp){
            //refresh the page
        }     
    });
    
    1. addPayment.php文件夹
    2. 中创建root/ajaxFiles/addPayment.php
      include("../config.php");
      $localhost = $sugar_config['dbconfig']['db_host_name'];
      $user = $sugar_config['dbconfig']['db_user_name'];
      $password = $sugar_config['dbconfig']['db_password'];
      $db_name = $sugar_config['dbconfig']['db_name'];
      $recordId= $_POST['record'];
      //write a query to update the status of the field
      

      希望这能解决您的问题。感谢。