echo '<title>Norex Code Generator</title>'; echo '<script type="text/javascript" src="/js/prototype.js"></script>'; echo '<script type="text/javascript" src="/js/scriptaculous.js"></script>'; echo '</head>'; echo '<body>'; echo $form->display(); if ($form->validate()) { $sql = 'describe ' . $_REQUEST['table']; $cols = Database::singleton()->query_fetch_all($sql); @($table_form = new Form()); @$table_form->addElement('hidden', 'table'); $table_form->setConstants(array('table' => $_REQUEST['table'])); @$table_form->addElement('text', 'class_name', 'Class Name'); foreach ($cols as $col) { $group = array(); $group[] = @$table_form->createElement('text', 'name', 'Name of ' . $col['Field']); if ($col['Key'] == "PRI") { $priKey = $col['Field']; } $group[] = @$table_form->createElement('select', 'type', 'Type of ' . $col['Field'], $classnames); $table_form->addGroup($group, 'cols[' . $col['Field'] . ']', 'Name of ' . $col['Field'], ' '); } @$table_form->addElement('submit', 'submit', 'Submit'); echo $table_form->display(); if ($table_form->validate() && @$_REQUEST['class_name']) { $smarty->assign('class', @$_REQUEST['class_name']); $cols = array(); foreach ($_REQUEST['cols'] as $key => $col) { $cols[$key] = $col['name']; } $smarty->assign('cols', @$_REQUEST['cols']);
public function getVoteForm($hash) { if ($this->checkHash($hash) == $this->id) { $form = new Form('vote', 'POST', '/Vote/' . $hash, ''); $choices = array(); foreach ($this->getChoices() as $choice) { if (count($this->getChoices($choice->getId())) > 0) { $options = array(); foreach ($this->getChoices($choice->getId()) as $option) { $options[] =& $form->createElement('radio', null, null, $option->getChoice(), $option->getId()); } $form->addGroup($options, 'vote_choice[' . $choice->getId() . ']', $choice->getChoice(), '<br/>'); } } $form->addElement('hidden', 'vote_submit', null, true); $form->addElement('submit', 'submit', 'Vote'); return $form; } return false; }
public function getAddEditForm($target = '/admin/Campaigns§ion=recipaddedit') { $form = new Form('campaign_recipient_addedit', 'POST', $target, '', array('class' => 'admin')); $form->addElement('text', 'name', 'Name'); $form->addElement('text', 'email', 'E-mail'); $chk =& $form->createElement('select', 'contact_type', 'Contact type', array("admin" => "Admin", "result" => "Result viewer", "normal" => "Normal user")); $form->addElement($chk); $form->addElement('hidden', 'group_id', $this->group); $form->addElement('submit', 'submit', 'Submit'); $form->addRule('name', 'Please enter a recipient name', 'required'); $form->addRule('email', 'Please enter an email address', 'required'); if (!is_null($this->id)) { $form->setConstants(array('recipient_id' => $this->getId())); $form->addElement('hidden', 'recipient_id'); $defaultValues['name'] = $this->getName(); $defaultValues['email'] = $this->getEmail(); $defaultValues['contact_type'] = $this->getContactType(); } else { $defaultValues['contact_type'] = "normal"; } $form->setDefaults($defaultValues); if ($form->isSubmitted() && isset($_POST['submit'])) { if ($form->validate()) { $this->name = $form->exportValue('name'); $this->email = $form->exportValue('email'); $this->type = $form->exportValue('contact_type'); $this->save(); } } return $form; }