function _setFormField($form, $config) { parent::_setFormField($form, $config); $form->addRule('siteconfig_value', 'Number required', 'numeric', '', 'client'); }
public function getAddEditForm($target = '/admin/SiteConfig') { $form = new Form('SiteConfig_addedit', 'post', $target); $form->setConstants(array('action' => 'addedit', 'NOREX' => NOREX)); $form->addElement('hidden', 'action'); if (NOREX) { $form->addElement('hidden', 'NOREX'); } if (!is_null($this->getId())) { $form->setConstants(array('siteconfig_id' => $this->getId())); $form->addElement('hidden', 'siteconfig_id'); // $defaultValues ['siteconfig_value'] = $this->getRawValue(); // $form->setDefaults( $defaultValues ); } else { if (!NOREX) { error_log("Attempt was made to create a new config option."); die; } } if (!NOREX) { $form->addElement('html', 'siteconfig_description', 'Description')->setValue($this->getDescription()); SiteConfigType::setFormField($form, $this); } else { $form->addElement('html', 'Types are: ' . SiteConfigType::getTypeList() . '.<br/>An example of enum is "enum(yes, no, maybe)".'); $form->addElement('text', 'siteconfig_module', 'Module')->setValue($this->getModule()); $form->addElement('text', 'siteconfig_name', 'Name')->setValue($this->getName()); $form->addElement('text', 'siteconfig_description', 'Description')->setValue($this->getDescription()); $form->addElement('text', 'siteconfig_type', 'Type')->setValue($this->getRawType()); $form->addElement('text', 'siteconfig_sort', 'Sort')->setValue($this->getSort()); SiteConfigType::setFormField($form, $this); } $form->getElement('siteconfig_value')->setValue(SiteConfigType::getDisplayString($this)); $form->addElement('submit', 'siteconfig_submit', 'Submit'); if ($form->validate() && $form->isSubmitted() && isset($_REQUEST['siteconfig_submit'])) { if (NOREX) { $this->setModule($form->exportValue('siteconfig_module')); $this->setName($form->exportValue('siteconfig_name')); $this->setDescription($form->exportValue('siteconfig_description')); $this->setType($form->exportValue('siteconfig_type')); $this->setSort($form->exportValue('siteconfig_sort')); } $this->setValue($form->exportValue('siteconfig_value')); $this->save(); } return $form; }