简体   繁体   English

基于用户的橙色HRM隐藏表单值。 基于Symfony框架

[英]Orange HRM Hidden Form Values based on User. Based on Symfony Framework

I was tasked with changing the form in the our in-house HR App which is based on OrangeHRM. 我的任务是在我们基于OrangeHRM的内部HR App中更改表格。

FileName: AddEmployeeForm.php 文件名: AddEmployeeForm.php

Form code: 表单代码:

  $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)),

I have added most of the form however the widgets need special attetion: 我已经添加了大多数表单,但是小部件需要特别注意:

'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)),

The scenario is there are two users: PIM and IT once the PIM submits the form. 该方案有两个用户:PIM和IT,一旦PIM提交了表单。 Once the form is submitted the IT user will prompted with these fields to populate. 提交表单后,IT用户将提示输入这些字段。 However these fields are not able to be viewed by the PIM. 但是,PIM无法查看这些字段。

My question is there any way to modify these fields based on the above scenario? 我的问题是有什么办法可以根据上述情况修改这些字段?

I suppose your users are segregated in groups, so you could try something like this: 我想您的用户是按组划分的,因此您可以尝试执行以下操作:

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');
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM