/** * Set attributes to field * @param \FormularField $Field * @param array $options */ private function setAttributesToField(\FormularField &$Field, array &$options) { if (!empty($options['unit'])) { $Field->setUnit($options['unit']); } if (!empty($options['size'])) { $Field->setSize($options['size']); } if (!empty($options['css'])) { $Field->addLayoutClass($options['css']); } if (!empty($options['layout'])) { $Field->setLayout($options['layout']); } }
/** * Set attributes to field * @param FormularField $Field * @param array $FieldArray */ private function setAttributesToField(FormularField &$Field, &$FieldArray) { if (isset($FieldArray['formular']['parser'])) { $Options = array(); if (isset($FieldArray['formular']['required'])) { $Options['required'] = $FieldArray['formular']['required']; } if (isset($FieldArray['formular']['parserOptions'])) { $Options = array_merge($Options, $FieldArray['formular']['parserOptions']); } $Field->setParser($FieldArray['formular']['parser'], $Options); } if (isset($FieldArray['formular']['unit'])) { $Field->setUnit($FieldArray['formular']['unit']); } if (isset($FieldArray['formular']['size'])) { $Field->setSize($FieldArray['formular']['size']); } if (isset($FieldArray['formular']['css'])) { $Field->addLayoutClass($FieldArray['formular']['css']); } if (isset($FieldArray['formular']['layout'])) { $Field->setLayout($FieldArray['formular']['layout']); } if ($this->fieldClass($FieldArray) == 'FormularSelectDb') { $Field->loadOptionsFrom($FieldArray['formular']['table'], $FieldArray['formular']['column']); } }
/** * Construct new input field for: splits * * WARNING: This class was used with @code new TrainingInputSplits([$value]); @endcode previously. * To be used in a standard formular created by a database scheme, * this class has to use the default constructor for a FormularField again: * @code new TrainingInputSplits($name, $label [, $value]); @endcode * * @param string $name * @param string $label * @param string $value [optional] */ public function __construct($name = '', $label = '', $value = '') { if ($label == '') { parent::__construct('splits', __('Laps'), $name); } else { parent::__construct($name, $label, $value); } $this->setLayout(FormularFieldset::$LAYOUT_FIELD_W100_IN_W50); $this->addAttribute('class', FormularInput::$SIZE_FULL_INLINE); $this->setParser(FormularValueParser::$PARSER_SPLITS); }
/** * Check for submit, therefore all fields must be set */ protected function checkForSubmit() { if (!$this->wasSubmitted) { return; } $this->validateAllFieldsets(); $Failures = FormularField::getValidationFailures(); if (empty($Failures)) { $this->dataObject->setFromArray($_POST); if ($this->submitMode == self::$SUBMIT_MODE_CREATE) { $this->dataObject->insert(); } elseif ($this->submitMode == self::$SUBMIT_MODE_EDIT) { $this->dataObject->update(); } } foreach ($Failures as $message) { $this->addFailure($message); } if (!$this->submitSucceeded() || $this->submitMode == self::$SUBMIT_MODE_EDIT) { $this->initFieldsets(); } }
/** * Construct a new field * @param string $name * @param string $label * @param string $value optional, default: loading from $_POST */ public function __construct($name, $label, $value = '') { parent::__construct($name, $label, $value); $this->setParser(FormularValueParser::$PARSER_BOOL); }
<fieldset> <legend onclick="show('log');"><?php _e('Create a new account'); ?> </legend> <?php if (!USER_CAN_REGISTER) { echo HTML::error(__('Registrations are currently disabled.')); } else { if (isset($_POST['new_username'])) { $Errors = AccountHandler::tryToRegisterNewUser(); if (is_array($Errors)) { foreach ($Errors as $Error) { if (is_array($Error)) { foreach (array_keys($Error) as $FieldName) { FormularField::setKeyAsFailed($FieldName); } } } } } FormularInput::setStandardSize(FormularInput::$SIZE_MIDDLE); $Field = new FormularInput('new_username', __('Username')); $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W100); $Field->setUnit(FormularUnit::$USER); $Field->display(); $Field = new FormularInput('name', __('Name')); $Field->setLayout(FormularFieldset::$LAYOUT_FIELD_W100); $Field->setUnit(FormularUnit::$USER); $Field->display(); $Field = new FormularInput('email', __('Email'));