public function render($settings) { $this->settings = $settings; foreach ($this->settings as $id => $values) { switch ($values['type']) { case 'html': $this->output .= '<div id="' . $id . '">' . $values['value'] . '</div>'; break; case 'form': $form = new Form($values['value']); $this->output .= $form->build(); break; } } return $this->output; }
*/ $inp_dir = new Input(); $inp_dir->setName('directory'); $inp_dir->setSize(50); $inp_dir->setValue($result->directory); $inp_ext = new Input(); $inp_ext->setName('extension'); $inp_ext->setSize(10); $inp_ext->setValue($result->extension); $inp_lines = new Input(); $inp_lines->setName('nr_rows'); $inp_lines->setSize(7); $inp_lines->setValue($result->nr_rows); $form = new Form(); $form->setAction('controller.php'); $form->build(); $table = new Table(); $table->build(); $tr = new Tr(); $tr->add('Directory : '); $tr->add($inp_dir->dump()); $tr->add($cmd->dump()); $tr->build(); $tr = new Tr(); $tr->add('Extension : '); $tr->add($inp_ext->dump()); $tr->build(); $tr = new Tr(); $tr->add('# records in view : '); $tr->add($inp_lines->dump()); $tr->build();
private function _ConfModal($mode, $icon, $type, $action, $auth = false, $conf = false, $prompt = '', $cust = false) { $mod_id = substr(crc32(microtime()), 1, 6); if ($prompt == '') { $prompt = '<p>Are you sure you want to ' . $mode . ' the following ' . $type . ':</p>'; } $mod_content = $prompt . PHP_EOL; $mod_content .= '<ul id="' . $mode . '_' . $type . '"></ul>' . PHP_EOL; $mod_form = new Form($mode . '_f', $action, 'post', 'application/x-www-form-urlencoded', $mode . '_' . $type . '(); return false;'); $mod_form->setColumns(4, 8); $mod_form->addHiddenField($type, '', $type . '_to_' . $mode); if ($auth) { $mod_form->addPasswordField('Your Password', 'pwd', '', array('t' => 'Your password to confirm the operation', 'p' => 'Your Password'), array('t' => 'password', 'r' => true)); } if ($conf) { $mod_form->addButtonGroup('Are you sure?', 'conf', array(array('i' => 'confY' . $mod_id, 's' => B_T_SUCCESS, 'v' => 1, 'l' => 'Yes', 'c' => false), array('i' => 'confN' . $mod_id, 's' => B_T_FAIL, 'v' => 0, 'l' => 'No', 'c' => true)), array('t' => 'Are you sure you wish to perform this action?')); } $mod_form->build(); $mod_content .= $mod_form->getForm(); $mod = new Modal(); $mod->setID($mode); $mod->setTitle(ucfirst($mode) . ' ' . ucfirst($type) . '?'); $mod->setBody($mod_content); $mod->setLeft('default', 'Cancel', 'remove-sign', 'button', '$(\'#' . $mode . '\').modal(\'hide\')'); $mod->setRight('danger', 'OK', $icon, 'button', $mode . '_' . $type . '(this)'); $mod->create(); $this->comps[] = $mod->getModal(); $this->_addConfModalScript($mode, $type, $cust); }
<head> <title>Testing form validation and building</title> </head> <body> <? if ( !$FORM->is_valid() ): ?> <ul id="errors"> <? foreach ( $FORM->errors() as $error ): ?> <li><?= $error ?></li> <? endforeach; ?> </ul> <? endif; ?> <?= $FORM->errors_as_html() ?> <form action="#" method="POST"> <label class="<?= $FORM['name']['valid'] ?> <?= $FORM['name']['required'] ?>"> <?= $FORM['name']['label'] ?>: <input type="text" id="name" name="name" value="<?= $FORM['name'] ?>" /> </label> <label class="<?= $FORM['email_address']['valid'] ?> <?= $FORM['email_address']['required'] ?>"> <?= $FORM['email_address']['label'] ?>: <input type="text" id="email_address" name="email_address" value="<?= $FORM['email_address'] ?>" /> </label> <?= $FORM->build() # everything INSIDE the FORM element ?> </form> </body> </html>
</body> </html> <?php } else { //ログイン済 $part_hidden = array('part' => 'input', 'type' => 'hidden', 'name' => 'zone', 'value' => $zone_id); $data->select_all($zone); $part = array('part' => 'select', 'name' => 'group', 'selected' => $zone_id); while ($row = $data->fetch()) { $part["option"]["{$row["id"]}"] = str_pad($row["id"], 3, "0", STR_PAD_LEFT) . ":" . $row["name"]; } ?> <h3>* * Monster List * *</h3> <?php echo $form->start(); echo $form->build($part_hidden); echo $form->submit("logout", "ログアウト"); ?> <div> モンスターリストに新規追加<br> <?php echo $form->load_xml_file($form_add_xml); ?> </div> <hr> <div> ゾーン <?php echo $form->build($part); echo $form->submit("group", "表示"); ?>
<h3>* * Status Data * *</h3> <?php echo $form->start(); echo $form->submit("logout", "ログアウト"); ?> <hr> <div> ステータスデータに新規追加<br> <?php echo $form->load_xml_file($form_add_xml); ?> </div> <hr> <div> <?php echo $form->build($select_part); echo $form->submit("table", "表示"); ?> </div> <hr> <?php $data->select_all($table); $count = $data->rows(); while ($row = $data->fetch()) { $row["lv"] = num_length($row["lv"]); ?> <div> <?php echo $form->load_xml_string(xml_status_form_upd($row)); ?> </div>