submit(), save(), save_and_back(), save_and_clear(), preview() form()

Submit buttons: submit(), save() with an icon, save_and_back() / save_and_clear() with a Back / Clear link, preview().

form()->submit($name = '', $value = '', $extra = [], $replace = [])
form()->save($name = '', $desc = '', $extra = [], $replace = [])
form()->save_and_back($name = '', $desc = '', $extra = [], $replace = [])
form()->save_and_clear($name = '', $desc = '', $extra = [], $replace = [])
form()->preview($name = '', $value = '', $extra = [], $replace = [])

Options

OptionMeaning
$name, valuePosted name and value; the value (default Save) is the button text.
descButton text instead of the value.
iconIcon class; save*() default CLASS_ICON_SAVE, preview() CLASS_ICON_PREVIEW.
class, class_add, sizingDefault CLASS_BTN_SUBMIT; size xs, sm, lg.
link_url, link_nameA link next to the button; save_and_back() takes $replace['back_link'] (or back_url), save_and_clear() clear_link / clear_url.
as_input<input type="submit"> instead of <button>.
no_escape, disabled, targetHTML in the value; attributes.

Example

Back
Clear

Code

return form(['back_link' => '/docs/form', 'clear_link' => '/docs/form/submit'])
    ->text('title')
    ->submit(['value' => 'Send'])
    ->save()
    ->save_and_back()
    ->save_and_clear()
    ->preview();

Notes

  • The back / clear link is shown only when it holds a /.
  • The button text is translated with t().

Bootstrap 3 and 5

CLASS_BTN_SUBMIT is btn btn-default btn-primary (Bootstrap 3) or btn btn-primary (5).

See also: form/button, form/link