Exemplo n.º 1
0
 public function configure()
 {
     $status = array('Enabled' => __('Enabled'), 'Disabled' => __('Disabled'));
     $idGenService = new IDGeneratorService();
     $idGenService->setEntity(new Employee());
     $empNumber = $idGenService->getNextID(false);
     $employeeId = str_pad($empNumber, 4, '0');
     $this->widgets = array('firstName' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30)), 'middleName' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30)), 'lastName' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 30)), 'empty' => new ohrmWidgetDiv(), 'fullNameLabel' => new ohrmWidgetDiv(), 'firstNameLabel' => new ohrmWidgetDiv(), 'middleNameLabel' => new ohrmWidgetDiv(), 'lastNameLabel' => new ohrmWidgetDiv(), 'employeeId' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 10, "colspan" => 3)), 'photofile' => new sfWidgetFormInputFileEditable(array('edit_mode' => false, 'with_delete' => false, 'file_src' => ''), array("class" => "duplexBox", "colspan" => 3)), 'chkLogin' => new sfWidgetFormInputCheckbox(array('value_attribute_value' => 1), array("style" => "vertical-align:top", "colspan" => 3)), 'lineSeperator' => new ohrmWidgetDiv(array(), array("colspan" => 3)), 'user_name' => new sfWidgetFormInputText(array(), array("class" => "formInputText", "maxlength" => 20)), 'status' => new sfWidgetFormSelect(array('choices' => $status), array("class" => "formInputText", "br" => true)), 'user_password' => new sfWidgetFormInputPassword(array(), array("class" => "formInputText passwordRequired", "maxlength" => 20)), 're_password' => new sfWidgetFormInputPassword(array(), array("class" => "formInputText passwordRequired", "maxlength" => 20, "br" => true)), 'empNumber' => new sfWidgetFormInputHidden());
     $this->widgets['empNumber']->setDefault($empNumber);
     $this->widgets['employeeId']->setDefault($employeeId);
     if ($this->getOption('employeeId') != "") {
         $this->widgets['employeeId']->setDefault($this->getOption('employeeId'));
     }
     $this->widgets['firstName']->setDefault($this->getOption('firstName'));
     $this->widgets['middleName']->setDefault($this->getOption('middleName'));
     $this->widgets['lastName']->setDefault($this->getOption('lastName'));
     $this->widgets['chkLogin']->setDefault($this->getOption('chkLogin'));
     $this->widgets['user_name']->setDefault($this->getOption('user_name'));
     $this->widgets['user_password']->setDefault($this->getOption('user_password'));
     $this->widgets['re_password']->setDefault($this->getOption('re_password'));
     $this->widgets['status']->setDefault($this->getOption('status'));
     $this->setWidgets($this->widgets);
     $this->setValidators(array('photofile' => new sfValidatorFile(array('max_size' => 1000000, 'required' => false)), 'firstName' => new sfValidatorString(array('required' => true, 'max_length' => 30, 'trim' => true)), 'empNumber' => new sfValidatorString(array('required' => false)), 'lastName' => new sfValidatorString(array('required' => true, 'max_length' => 30, 'trim' => true)), 'middleName' => new sfValidatorString(array('required' => false, 'max_length' => 30, 'trim' => true)), 'employeeId' => new sfValidatorString(array('required' => false, 'max_length' => 10)), 'chkLogin' => new sfValidatorString(array('required' => false)), 'user_name' => new sfValidatorString(array('required' => false, 'max_length' => 20, 'trim' => true)), 'user_password' => new sfValidatorString(array('required' => false, 'max_length' => 20, 'trim' => true)), 're_password' => new sfValidatorString(array('required' => false, 'max_length' => 20, 'trim' => true)), 'status' => new sfValidatorString(array('required' => false))));
     $this->getWidgetSchema()->setLabels($this->getFormLabels());
     sfWidgetFormSchemaFormatterAddEmployee::setNoOfColumns(4);
     //merge location dropdown
     $formExtension = PluginFormMergeManager::instance();
     $formExtension->mergeForms($this, 'addEmployee', 'AddEmployeeForm');
     $this->widgetSchema->setFormFormatterName('AddEmployee');
 }
 /**
  *
  * @return string
  */
 protected function getTrEnd($field)
 {
     $br = '';
     if ($this->getAttr($field, 'br') == '') {
         self::$elements = self::$elements + (int) $this->getAttr($field, 'colspan');
         if (self::$elements == self::$noOfColumns) {
             $br = '</tr>';
             self::$elements = 0;
         }
     } else {
         $br = '</tr>';
     }
     return $br;
 }