/** * Set field value * * @param FormElement $formField * @param string $presentation * @param string $value */ protected function setFieldValue($formField, $presentation, $value) { switch ($presentation) { case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX: $formField->setValue(true); break; default: $formField->setValue($value); } }
public function setValue($value) { if (!$value) { $this->_error = $this->get('title') . ' is required.'; return false; } if ($value != \Core\Session::Get('captcha')) { $this->_error = $this->get('title') . ' does not match image.'; return false; } parent::setValue(''); }
/** * Set field value * * @param FormElement $formField * @param string $presentation * @param string $value */ protected function setFieldValue($formField, $presentation, $value) { $value = BOL_QuestionService::getInstance()->prepareFieldValue($presentation, $value); $formField->setValue($value); }
/** * Create and return element of input tags whose type are checkbox * * @param string $name * @param array $list * @param string $defaultValue * @param array $attributes * @return FormElementSet */ public function createCheckboxes($name = null, $list = array(), $defaultValue = null, $attributes = null) { $this->_checkArgumentIsArray(__METHOD__, 2, $list); $frame = $this->createFormElementSet('span'); if (!is_array($attributes)) { $attributes = array(); } $attributes['type'] = 'checkbox'; if (is_array($list)) { foreach ($list as $value => $text) { $checkbox = new FormElement('input'); $checkbox->setIsReturnInner(false); $checkbox->setAttributes($attributes); $checkbox->setValue($value); $label = new HtmlElement('label'); $label->setIsReturnInner(false); $label->addElement($checkbox); $label->addNode($text); $frame->addElement($label); } } $frame->setName($name); if ($defaultValue !== null) { $frame->setValue($defaultValue); } return $frame; }
public function setValue($value) { parent::setValue($value); $this->addAttribute('value', $value); }
/** * Set field value * * @param FormElement $formField * @param string $presentation * @param string $value */ protected function setFieldValue($formField, $presentation, $value) { switch ($presentation) { case BOL_QuestionService::QUESTION_PRESENTATION_CHECKBOX: $formField->setValue(true); break; case BOL_QuestionService::QUESTION_PRESENTATION_AGE: case BOL_QuestionService::QUESTION_PRESENTATION_BIRTHDATE: case BOL_QuestionService::QUESTION_PRESENTATION_DATE: $date = UTIL_DateTime::parseDate($value, UTIL_DateTime::MYSQL_DATETIME_DATE_FORMAT); if (isset($date)) { $formField->setValue($date['year'] . '/' . $date['month'] . '/' . $date['day']); } break; case BOL_QuestionService::QUESTION_PRESENTATION_MULTICHECKBOX: $data = array(); $multicheckboxValue = (int) $value; for ($i = 0; $i < 31; $i++) { $val = (int) pow(2, $i); if ($val & $multicheckboxValue) { $data[] = $val; } } $formField->setValue($data); break; default: $formField->setValue($value); } }
/** * Returns defaut form element * @param $name * @param $data * @return FormElement */ protected function getFormElementPrototype($name, $data, $value = null) { //fixed form field name $schemaName = strtr($this->schemaFormat, array('%name%' => $name, '%counter%' => $this->counter, '%parent%' => $this->parentSchemaName)); $default = isset($data['default']) ? $data['default'] : null; $value = $value !== null ? $value : null; if ($value === null) { $value = $default; } $e = new FormElement($schemaName, isset($data['label']) ? ucfirst($data['label']) : $this->labelize($name)); $e->setValue($value); //setup default value $e->addCustomTags('data-default="' . $default . '"'); $e->description = isset($data['help']) ? $data['help'] : ''; return $e; }