/** * @param array $options The options to pass to the tag when rendering * * @return string The rendered label */ public function __invoke(array $options = []) { $options = array_merge(["for" => $this->field_id, "text" => $this->text], $options); $text = $options['text']; unset($options['text']); return sprintf("<label %s>%s</label>", html_params($options), $text); }
/** * @param Field $field * @param array $options * * @return string */ public function __invoke($field, array $options = []) { $options = array_merge(["id" => $field->id], $options); $options['name'] = $field->name; $options['type'] = "file"; return sprintf("<input %s>", html_params($options)); }
/** * @param Field $field * @param array $options * * @return string */ public function __invoke($field, array $options = []) { $defaults = ["id" => $field->id, "type" => $this->input_type, "value" => $field->value]; $options = array_merge($defaults, $options); $options['name'] = $field->name; return sprintf("<input %s>", html_params($options)); }
/** * Private method called when rendering each option as HTML * * @param mixed $value * @param string $label * @param boolean $selected * @param array $options * * @return string */ public static function renderOption($value, $label, $selected, $options = []) { if ($value === true) { // Handle the special case of a true value $value = "true"; } $options = array_merge($options, ["value" => $value]); if ($selected) { $options['selected'] = true; } return sprintf("<option %s>%s</option>", html_params($options), $label); }
/** * @param Field|mixed $field * @param array $options * * @return string */ public function __invoke($field, array $options = []) { $options = array_merge(["id" => $field->id], $options); $html = sprintf("<%s %s>", $this->html_tag, html_params($options)); if ($field instanceof SelectFieldBase) { $field = $field->options; } foreach ($field as $subfield) { if ($this->prefix_label) { $html .= sprintf("<li>%s %s</li>", $subfield->label, $subfield()); } else { $html .= sprintf("<li>%s %s</li>", $subfield(), $subfield->label); } } $html .= sprintf("</%s>", $this->html_tag); return $html; }
/** * @param Field $field * @param array $options * * @return string */ public function __invoke($field, array $options = []) { $html = ""; $hidden = ""; if ($this->with_table_tag) { $html .= sprintf("<table %s>", html_params(array_merge(['id' => $field->id], $options))); } foreach ($field as $subfield) { if (in_array($subfield->type, ['HiddenField', 'CSRFTokenField'])) { $hidden .= (string) $subfield; } else { $html .= sprintf("<tr><th>%s</th><td>%s%s</td></tr>", $subfield->label, $hidden, $subfield); $hidden = ""; } } if ($this->with_table_tag) { $html .= "</table>"; } if ($hidden) { $html .= $hidden; } return $html; }
/** * @param Field $field * @param array $options * * @return string */ public function __invoke($field, array $options = []) { $options = array_merge(["id" => $field->id], $options); $options['name'] = $field->name; return sprintf("<textarea %s>%s</textarea>", html_params($options), e($field->value)); }