我的任务是更改基于OrangeHRM的内部人力资源应用程序中的表单。
FileName: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提交表单,PIM和IT。 提交表单后,将提示IT用户填写这些字段。但是,PIM无法查看这些字段。
我的问题是有没有办法根据上述情况修改这些字段?
答案 0 :(得分: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');
}