public function format($data, $format = null) { if ($data == '0000-00-00') { $data = ''; } return parent::format($data, $format); }
public function format($data, $format = null) { $result = parent::format($data, $format); if (in_array('list', explode(',', $format))) { return $result ? _ws('Yes') : _ws('No'); } return $result; }
public function getInfo() { $info = parent::getInfo(); $tmp = $this->getOptions(); $info['parent_options'] = reset($tmp); $info['parent_field'] = key($tmp); return $info; }
public function getHtmlOne($params = array(), $attrs = '') { if ($this->getParameter('input_height') <= 1) { return parent::getHtmlOne($params, $attrs); } $value = isset($params['value']) ? $params['value'] : ''; return '<textarea ' . $attrs . ' name="' . $this->getHTMLName($params) . '">' . htmlspecialchars($value) . '</textarea>'; }
public function getInfo() { $data = parent::getInfo(); $data['options'] = $this->getOptions(); // In JS we cannot rely on the order of object properties during iteration // so we pass an order of keys as an array $data['oOrder'] = array_keys($data['options']); $data['defaultOption'] = _ws($this->getParameter('defaultOption')); return $data; }
/** * Set the value of parameter $p. * Used by a field constructor to change field parameters. * * waContactStringField has one parameter: input_height, integer from 1 to 5. * * @param string $p parameter to set * @param mixed $value value to set * @return void */ public function setParameter($p, $value) { if ($p == 'input_height') { $value = (int) $value; if ($value < 1) { $value = 1; } else { if ($value > 5) { $value = 5; } } $this->options['input_height'] = $value; } else { parent::setParameter($p, $value); } }
protected function init() { if (!isset($this->options['formats'])) { $this->options['formats'] = array(); } if (!isset($this->options['formats']['html'])) { $this->options['formats']['html'] = new waContactBirthdayLocalFormatter(array('prefix' => $this->options['prefix'])); } if (!isset($this->options['formats']['locale'])) { $this->options['formats']['locale'] = $this->options['formats']['html']; } if (!isset($this->options['formats']['list'])) { $this->options['formats']['list'] = $this->options['formats']['html']; } if (empty($this->options['validators'])) { $this->options['validators'] = new waDateValidator($this->options, array('required' => _ws('This field is required'))); } parent::init(); }
public function getFormatter($format) { if ($format == 'html') { return new waContactSelectFormatter($this->getOptions()); } return parent::getFormatter($format); }
/** * Reset field parameters that are normally saved in *_fields_order.php * to prepare $field object to be saved in *fields.php * @param waContactField $field */ protected static function resetCustomParameters($field) { foreach (self::$customParameters as $p => $def) { $field->setParameter($p, $def); } }
public function setParameter($p, $value) { if ($p === 'required') { if (!$value || !is_array($value)) { $value = array(); } } parent::setParameter($p, $value); }
private function signupFieldHTML(waContactField $f, $params, $error = '') { $data = waRequest::post('data'); // get value if (isset($params['parent'])) { $parent_value = $data[$params['parent']]; $params['value'] = isset($parent_value[$params['id']]) ? $parent_value[$params['id']] : ''; } else { $params['value'] = isset($data[$params['id']]) ? $data[$params['id']] : ''; } $config = wa()->getAuthConfig(); if (!empty($config['fields'][$f->getId()]['caption'])) { $name = htmlspecialchars($config['fields'][$f->getId()]['caption']); } else { $name = $f->getName(null, true); if (isset($params['ext'])) { $exts = $f->getParameter('ext'); if (isset($exts[$params['ext']])) { $name .= ' (' . _ws($exts[$params['ext']]) . ')'; } else { $name .= ' (' . $params['ext'] . ')'; } } } $params['namespace'] = 'data'; $is_multi = $f->isMulti(); if ($is_multi) { $f->setParameter('multi', false); } $attrs = $error !== false ? 'class="wa-error"' : ''; if (!empty($config['fields'][$f->getId()]['placeholder'])) { $attrs .= ' placeholder="' . htmlspecialchars($config['fields'][$f->getId()]['placeholder']) . '"'; } elseif (!empty($params['placeholder'])) { $attrs .= ' placeholder="' . htmlspecialchars($params['placeholder']) . '"'; } if ($f instanceof waContactHiddenField) { $html = $f->getHTML($params, $attrs); } else { $html = '<div class="wa-field wa-field-' . $f->getId() . '"> <div class="wa-name">' . $name . '</div> <div class="wa-value">' . $f->getHTML($params, $attrs); if ($error) { $html .= '<em class="wa-error-msg">' . $error . '</em>'; } $html .= '</div></div>'; } if ($is_multi) { $f->setParameter('multi', $is_multi); } return $html; }
public function getInfo() { $data = parent::getInfo(); $data['region_countries'] = array_fill_keys($this->getRegionCountries(), 1); return $data; }
public function setParameter($p, $value) { if ($p === 'required') { if (!$value || !is_array($value)) { $value = array(); } } parent::setParameter($p, $value); if ($p === 'fields') { $this->prepareSubfields(); } }
private function signupFieldHTML(waContactField $f, $params, $error = '') { $data = waRequest::post('data'); // get value if (isset($params['parent'])) { $parent_value = $data[$params['parent']]; $params['value'] = $parent_value[$params['id']]; } else { $params['value'] = isset($data[$params['id']]) ? $data[$params['id']] : ''; } $name = $f->getName(); if (isset($params['ext'])) { $exts = $f->getParameter('ext'); if (isset($exts[$params['ext']])) { $name .= ' (' . _ws($exts[$params['ext']]) . ')'; } else { $name .= ' (' . $params['ext'] . ')'; } } $params['namespace'] = 'data'; if ($f->isMulti()) { $f->setParameter('multi', false); } $html = '<div class="wa-field"> <div class="wa-name">' . $name . '</div> <div class="wa-value">' . $f->getHTML($params, $error !== false ? 'class="wa-error"' : ''); if ($error) { $html .= '<em class="wa-error-msg">' . $error . '</em>'; } $html .= '</div></div>'; return $html; }