コード例 #1
0
ファイル: Apply.php プロジェクト: robjcordes/nexnewwp
 protected function _additionalFields()
 {
     $query = new Daq_Db_Query();
     $result = $query->select("*")->from("Wpjb_Model_AdditionalField t")->where("field_for = 2")->where("is_active = 1")->execute();
     foreach ($result as $field) {
         if ($field->type == Daq_Form_Element::TYPE_FILE) {
             $e = new Daq_Form_Element_File("field_" . $field->getId(), Daq_Form_Element::TYPE_FILE);
         } else {
             $e = new Daq_Form_Element("field_" . $field->getId(), $field->type);
         }
         $e->setLabel($field->label);
         $e->setHint($field->hint);
         if ($field->type == Daq_Form_Element::TYPE_FILE) {
             $e->setDestination(Wpjb_List_Path::getPath("apply_file"));
         } else {
             $this->_add[] = "field_" . $field->getId();
         }
         if ($field->type != Daq_Form_Element::TYPE_CHECKBOX) {
             $e->setRequired((bool) $field->is_required);
         } else {
             $e->addFilter(new Daq_Filter_Int());
         }
         if ($field->type == Daq_Form_Element::TYPE_TEXT) {
             switch ($field->validator) {
                 case 1:
                     $e->addValidator(new Daq_Validate_StringLength(0, 80));
                     break;
                 case 2:
                     $e->addValidator(new Daq_Validate_StringLength(0, 160));
                     break;
                 case 3:
                     $e->addValidator(new Daq_Validate_Int());
                     break;
                 case 4:
                     $e->addValidator(new Daq_Validate_Float());
                     break;
             }
         }
         foreach ((array) $field->getOptionList() as $option) {
             $e->addOption($option->getId(), $option->getId(), $option->value);
         }
         $this->addElement($e, "apply");
     }
 }