本文整理汇总了PHP中FormElement::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP FormElement::setValue方法的具体用法?PHP FormElement::setValue怎么用?PHP FormElement::setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormElement
的用法示例。
在下文中一共展示了FormElement::setValue方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setFieldValue
/**
* 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);
}
}
示例2: setValue
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('');
}
示例3: setFieldValue
/**
* 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);
}
示例4: createCheckboxes
/**
* 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;
}
示例5: setValue
public function setValue($value)
{
parent::setValue($value);
$this->addAttribute('value', $value);
}
示例6: setFieldValue
/**
* 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);
}
}
示例7: getFormElementPrototype
/**
* 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;
}