public function __construct($reason, $origin, $others = array()) { C::guardIsString($reason); C::guardEach($others, "guardIsErrorValue"); $this->_reason = $reason; $this->_others = $others; $this->_dict = null; parent::__construct($origin); }
public function __construct($content) { C::guardEach($content, "guardIsHTML"); $this->_content = $content; }
public static function select($options, $default = null, $attributes = array()) { C::guardEach($options, "guardIsString"); return self::input("select", $attributes)->mapHTML(V::fn(function ($dict, $html) use($options, $attributes, $default) { $name = $html->attribute("name"); $value = $dict->value($name); if ($value === null) { $value == $default; } $attributes["name"] = $name; $options_html = array_map(function ($option) use($value) { if ($option !== $value) { return H::tag("option", array(), H::text($option)); } else { return H::tag("option", array("selected" => "selected"), H::text($option)); } }, $options); return H::tag("select", $attributes, H::harray($options_html)); }))->satisfies(V::fn(function ($value) use($options) { return in_array($value, $options); }), "Option not available."); }