0

我的任务是更改基于 OrangeHRM 的内部 HR 应用程序中的表格。

文件名:AddEmployeeForm.php

表格代码:

  $this->widgets = array(
            /* 
                Menyra sesi kodi arranzhon input format eshte e tille.

                Input button eshte i pari qe duhet te i pari pastaj duhet label forma


            */
            'employeeId' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 10, "colspan" => 3)),
            'firstName' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'lastName' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'personalNumber' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),

            'dateofBirth' => new sfWidgetFormI18nDate(array('culture' => 'en')),
            'gender' => new sfWidgetFormSelect(array('choices' => $gender), array("class" => "formInputText","br" => true)),
            'nationality' => new sfWidgetFormI18nChoiceCountry(array('culture' => 'en'),array("br" => true)),
            'martial_status' => new sfWidgetFormSelect(array('choices' => $martial_status), array("class" => "formInputText","br" => true)), 
            'contact_address' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'contact_phone' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'empty' => new ohrmWidgetDiv(),
            // Gender duhet me qene drop-down,Google search qysh duhet me bo dropdown.
            // Gjitheashtu Nationatily,Martial Status.
            // Contact Address dhe Contacnt phone nr munen mu kon tekstbokse.

             'emstatus' => new sfWidgetFormSelect(array('choices' => $emp_status), array("class" => "formInputText","br" => true)),
             'jbtitle' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),


             'photofile' => new sfWidgetFormInputFileEditable(array('edit_mode' => false, 'with_delete' => false, 'file_src' => ''), array("class" => "duplexBox", "colspan" => 3,"br" => true)),
//            'helpText' => new ohrmWidgetDiv(),  

             'bankName' => new sfWidgetFormSelect(array('choices' => $banks), array("class" => "formInputText","br" => true)), 
             'bankNumber' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
             'lineSeperator' => new ohrmWidgetDiv(array(), array("colspan" => 3,"br" => true)),
            'chkLogin' => new sfWidgetFormInputCheckbox(array('value_attribute_value' => 1), array("style" => "vertical-align:top", "colspan" => 3,"br" => true)),
            'user_name' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 20,"br" => true)),
            'status' => new sfWidgetFormSelect(array('choices' => $status), array("class" => "formInputText", "br" => true,"br" => true)),
            'user_password' => new sfWidgetFormInputPassword(array(), array("class" => "formInputText passwordRequired", "maxlength" => 20,"br" => true)),
            're_password' => new sfWidgetFormInputPassword(array(), array("class" => "formInputText passwordRequired", "maxlength" => 20, "br" => true)),
            'empNumber' => new sfWidgetFormInputHidden(),
            //'Nationality' => new sfWidgetFormSelect(array('choices' => Duhet mi marr prej databazes), array("class" => "formInputText", "br" => true)),

                'userID' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
                'job_email_adress' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
                'ac_SN' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
                'lp_SN' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
                'phone_imei' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),

我已经添加了大部分表单,但是小部件需要特别注意:

'userID' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'job_email_adress' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'ac_SN' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'lp_SN' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),
            'phone_imei' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30,"br" => true)),

场景是有两个用户:PIM 和 IT 一旦 PIM 提交表单。提交表单后,IT 用户将提示填写这些字段。但是,PIM 无法查看这些字段。

我的问题是有什么方法可以根据上述情况修改这些字段?

4

1 回答 1

0

我想您的用户是按组隔离的,所以您可以尝试这样的事情:

if (sfContext::getInstance()->getUser()->hasGroup('IT')) {
    $this->setWidget('my_field', new sfMyWidgetFormHtmlTextarea());
    $this->setValidator('my_field', new sfValidatorPass());
    $this->getWidgetSchema()->moveField('my_field', sfWidgetFormSchema::AFTER, 'another_base_field');

    $this->setWidget('my_another_field', new sfWidgetFormInput());
    $this->setValidator('my_another_field', new sfValidatorInteger());
    $this->getWidgetSchema()->moveField('my_another_field', sfWidgetFormSchema::AFTER, 'my_field');
}
于 2018-05-03T15:36:57.973 回答