public function __toString() { global $core; $list = $core->site->templates; if (!$list) { return '<p class="warn">There is no template available.</p>'; } $options = array_combine($list, $list); $this[self::OPTIONS] = array(null => '<auto>') + $options; return parent::__toString(); }
public function __toString() { global $core; try { $site = $core->site; $value = (int) $this['value']; $options = $core->models['forms']->select('nid, title')->where('nid = ? OR ((siteid = 0 OR siteid = ?) AND (language = "" OR language = ?))', $value, $site->siteid, $site->language)->order('title')->pairs; if (!$options) { $url = \Brickrouge\escape($core->site->path . '/admin/forms/new'); return <<<EOT <a href="{$url}" class="btn btn-info">Créer un premier formulaire...</a> EOT; } if ($this->type == 'select') { $options = array(null => '') + $options; } $this[self::OPTIONS] = $options; } catch (\Exception $e) { return \Brickrouge\render_exception($e); } return parent::__toString(); }
/** * Renders the object into an HTML string. * * Before rendering the object form elements are altered according to the {@link VALUES} and * {@link DISABLED} tags and previous validation errors. */ public function __toString() { $values = $this[self::VALUES]; $disabled = $this[self::DISABLED]; $name = $this->name; $errors = null; if ($name) { $errors = retrieve_form_errors($name); } if ($values || $disabled || $errors) { if ($values) { $values = array_flatten($values); } if (!$errors) { $errors = new Errors(); } $this->alter_elements($values, $disabled, $errors); } return parent::__toString(); }