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 = [])Опції
| Опція | Значення |
|---|---|
$name, value | Posted name and value; the value (default Save) is the button text. |
desc | Button text instead of the value. |
icon | Icon class; save*() default CLASS_ICON_SAVE, preview() CLASS_ICON_PREVIEW. |
class, class_add, sizing | Default CLASS_BTN_SUBMIT; size xs, sm, lg. |
link_url, link_name | A 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, target | HTML in the value; attributes. |
top_save | false: no compact copy of this button at the top of a long form (see the notes). |
top_save_rows | On any row: its weight in rows for the top-save threshold instead of the default. |
Приклад
Код
return form(['back_link' => '/docs/form', 'clear_link' => '/docs/form/submit'])
->text('title')
->submit(['value' => 'Send'])
->save()
->save_and_back()
->save_and_clear()
->preview();Примітки
- The back / clear link is shown only when it holds a
/. - The button text is translated with
t(). - Top save (
TOP_SAVE): a form taller than a screen gets a compact copy of its first submit button at the top, right-aligned, with the same name and value and no id. On in the admin, off on the user side ($PROJECT_CONF['form2']['TOP_SAVE']: true / false everywhere; per form thetop_saveparam). It shows when the rows before the button weighTOP_SAVE_MIN_ROWS(12) or more (a textarea 3, a rich editor 8, tabs their bar plus the longest tab); the assetyf_form_top_savehides it while the form fits in the window. Not in filter, stpl, ajax (modal) answers, nor when the first submit is a preview.
Bootstrap 3 and 5
CLASS_BTN_SUBMIT is btn btn-default btn-primary (Bootstrap 3) or btn btn-primary (5).
Див. також: form/button, form/link, demo:form/top_save