0

I was tasked with changing the form in the our in-house HR App which is based on OrangeHRM.

FileName: 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. Once the form is submitted the IT user will prompted with these fields to populate. However these fields are not able to be viewed by the PIM.

My question is there any way to modify these fields based on the above scenario?

Scath
  • 3,673
  • 10
  • 27
  • 36
Bentnew
  • 1
  • 2
  • Your question seems to be about the code, but then the concrete question more about the use case. Please explain in detail the expected and actual outcome. Removal of non-english comments and attention to indentation shows effort. – Karl Richter May 04 '18 at 13:18

1 Answers1

0

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');
}
nikoskip
  • 1,739
  • 1
  • 19
  • 36