/** * @param Field|SelectField $field * @param array $options * * @return string */ public function __invoke($field, array $options = []) { $options = array_merge(["id" => $field->id], $options); $options['name'] = $field->name; if ($this->multiple) { $options['multiple'] = true; } $html = sprintf("<select %s>", html_params($options)); foreach ($field->getChoices() as list($value, $label, $selected)) { $html .= self::renderOption($value, $label, $selected); } $html .= "</select>"; return $html; }
/** * @inheritdoc */ public function __construct(array $options = []) { $options = array_merge(["widget" => new CheckboxInput()], $options); if (array_key_exists("false_values", $options) && is_array($options['false_values'])) { $this->false_values = $options['false_values']; unset($options['false_values']); } parent::__construct($options); }
/** * @inheritdoc */ public function __get($name) { if ($name == "value") { if ($this->raw_data) { return implode(" ", $this->raw_data); } if ($this->data instanceof Carbon) { return $this->data->formatLocalized(str_replace("%s", "%S", str_replace("%i", "%M", $this->format))); } elseif ($this->data instanceof \DateTime) { return Carbon::instance($this->data)->formatLocalized(str_replace("%s", "%S", str_replace("%i", "%M", $this->format))); } else { return ''; // @codeCoverageIgnore } } return parent::__get($name); // @codeCoverageIgnore }
/** * @inheritdoc */ public function __get($name) { if ($name == "options") { $this->options = []; $opts = ['widget' => $this->option_widget, 'name' => $this->name, 'form' => $this->form, 'meta' => $this->meta]; $i = 0; foreach ($this->getChoices() as list($value, $label, $selected)) { $opts['id'] = "{$this->id}-{$i}"; $opts['label'] = $label; $i++; $opt = new _Option($opts); $opt->process([], $value); $opt->checked = $selected; $this->options[] = $opt; } return $this->options; } return parent::__get($name); // @codeCoverageIgnore }
public function __construct(array $options = []) { $options = array_merge(["widget" => new TextInput()], $options); parent::__construct($options); }
/** * @inheritdoc */ public function __get($name) { if (in_array($name, ["data", "errors"]) || property_exists($this->form, $name)) { return $this->form->{$name}; } if (array_key_exists($name, $this->form->fields)) { return $this->form[$name]; } return parent::__get($name); // @codeCoverageIgnore }
/** * @inheritdoc */ public function __get($name) { if ($name == "data") { $ret = []; foreach ($this->entries as $entry) { $ret[] = $entry->data; } return $ret; } return parent::__get($name); //@codeCoverageIgnore }