Skip to content
Viames Marino edited this page Feb 26, 2026 · 2 revisions

Pair framework: Button

Pair\Html\FormControls\Button renders <button> controls with submit/reset/button modes and form-related attributes.

Methods

  • type(string $type): self where type is submit, reset, or button
  • formaction(string $url): static
  • formenctype(string $type): static
  • formmethod(string $method): static (get or post)
  • formnovalidate(bool $novalidate = true): static
  • formtarget(string $target): static
  • popovertarget(string $elementId): static
  • popovertargetaction(string $action): static (hide, show, toggle)
  • render(): string
  • validate(): bool

Behavior

  • Default button type is submit.
  • Caption text comes from inherited caption(...).
  • validate() always returns true.
  • Popover helpers generate data-popovertarget and data-popovertargetaction attributes.

Examples

Submit button with custom form endpoint:

$save = (new \Pair\Html\FormControls\Button('save'))
    ->caption('Save order')
    ->type('submit')
    ->formaction('/orders/save')
    ->formmethod('post')
    ->formenctype('multipart/form-data');

echo $save->render();

Popover trigger button:

$help = (new \Pair\Html\FormControls\Button('help'))
    ->caption('Help')
    ->type('button')
    ->popovertarget('help-popover')
    ->popovertargetaction('toggle');

See also: FormControl, Form, Toggle.

Clone this wiki locally