/** * Check the format of the submitted value * * @param Form $form The form the input is associated with * * @return boolean true if the submitted value is a correct email, else false */ public function check(&$form = null) { if (parent::check($form)) { if (!empty($this->compare) && $form) { if ($form->getData($this->compare) != $this->value) { $form->error($this->errorAt, Lang::get("form.email-comparison")); return false; } } return true; } else { return false; } }
/** * Check the submitted value * * @param Form $form The form to apply the errors on in case of check failure * * @return bool the check status */ public function check(&$form = null) { // First check the global input validators if (!parent::check($form)) { return false; } if ($this->value != "") { // Check the format of the given date $tmp = date_parse_from_format($this->format, $this->value); if (empty($tmp)) { $form->error($this->errorAt, Lang::get('form.date-format')); return false; } // Check the date is valid if (!checkdate($tmp['month'], $tmp['day'], $tmp['year'])) { $form->error($this->errorAt, Lang::get('form.invalid-date')); return false; } } return true; }
/** * draw the form for creating new items. * May be overwritten if standard Display should not be used! */ function draw_new() { global $db, $lang, $go, $oid, $newitem, $errors, $page_action; $newitem = value("newitem"); $oid = value("oid", "NUMERIC"); $go = value("go", "NOSPACES"); //needed for uniqueness checks. $page_action = "INSERT"; $go = "UPDATE"; $container = new Container(4); $container->add(new Label("lbl", $lang->get("selectobject"), "informationheader", 3)); $container->add(new Cell("clc", "cwhite", 1, 20,10)); $container->add(new Cell("clc", "cwhite", 1, 150,10)); $container->add(new Cell("clc", "cwhite", 1, 350,10)); // what data should be displayed // check if item is selected. $stdStyle = "standardlight"; if ($this->state == creating && $newitem == "0") { $errors .= "-MANDATORY"; $stdStyle = "error"; $container->add(new Label("lbl", $lang->get("selectone"), "error", 3)); } $sql = "SELECT " . $this->new_pkname . ", " . $this->new_name . ", " . $this->new_description . " FROM " . $this->new_table . " ORDER BY " . $this->new_name; $query = new query($db, $sql); while ($query->getrow()) { $pk = $query->field($this->new_pkname); $checked = false; if (value("newitem", "NUMERIC") == $pk) $checked = true; $container->add(new Radio("newitem", $pk, $stdStyle, $checked)); $container->add(new Label("name", $query->field($this->new_name), "standard", 2)); $container->add(new Cell("clc", "standard", 1)); $container->add(new Label("desc", $query->field($this->new_description), "description", 2)); } $nameinput = new TextInput($lang->get("name"), $this->item_table, $this->item_name, "1", "type:text,size:32,width:200", "UNIQUE&MANDATORY"); $nameinput->setFilter($this->item_parentKeyName . " = $oid"); $positioninput = new TextInput($lang->get("position"), $this->item_table, "POSITION", "1", "type:text,size:3,width:30", "MANDATORY", "NUMBER"); if ($this->state == "creating") { $nameinput->check(); $positioninput->check(); } $container->add(new Cell("cll", "standard", 3, 10, 10)); $container->add(new Cell("cll", $nameinput->std_style, 1, 10, 1)); $container->add($nameinput); $container->add(new Cell("cll", $positioninput->std_style, 1, 10, 1)); $container->add($positioninput); // drawing. echo drawSpacer(1,1)."</td><td>".drawSpacer(1,1)."</td></tr>"; // cleanup the shit. echo "<tr><td colspan=\"2\"><br>"; echo '<table width="100%" cellpadding="0" cellspacing="0" border="0">'; $container->draw(); echo '</table>'; echo '</td></tr>'; echo '<tr><td colspan="2" align="right">'; echo '<br/>'; $resetbutton = new Button("reset", $lang->get("reset"), "navelement", "reset"); $resetbutton->draw(); echo drawSpacer(50,1); $backbutton = new Button("back", $lang->get("back"), "navelement", "submit"); $backbutton->draw(); echo ' '; $submitbutton = new Button("neu", $lang->get("create"), "navelement", "submit"); $submitbutton->draw(); retain("oid", $oid); retain("action", "editobject"); }