["?content", null, "libellé du bouton"], "type" => ["?string", "button", "type de submit: button, link"], "href" => "?string", # pour le type link "target" => "?string", # pour le type link "class" => ["?array", "btn-default"], #XXX ajouter type pour contrôler le type de bouton (default, primary, etc.) ]; /** @var array|string */ protected $ppSubmit; protected $tag, $tagAttrs; function pp_setType(?string $type="button"): void { switch ($type) { case "link": case "a": $this->tag = "a"; $this->tagAttrs = null; break; case "button": case "submit": case "b": $this->tag = "button"; $this->tagAttrs = ["type" => "submit"]; break; default: throw ValueException::invalid_value($type, "submit type"); } } /** @var ?string */ protected $ppHref; /** @var ?string */ protected $ppTarget; function getLayout(array $control): array { return $this->getFgsLayout($control, true); } function getControl(): array { $control = v::tag($this->tag, [ $this->tagAttrs, "id" => $this->ppId, "name" => $this->ppName, "value" => $this->ppValue, "href" => $this->ppHref, "target" => $this->ppTarget, "class" => ["btn", $this->ppClass], "style" => $this->ppStyle, $this->ppAttrs, q($this->ppSubmit), ]); if ($this->ppNaked) return $control; else return $this->getLayout($control); } }