Цю сторінку ще не перекладено українською, тому нижче англійська версія.

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, 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.
top_savefalse: no compact copy of this button at the top of a long form (see the notes).
top_save_rowsOn any row: its weight in rows for the top-save threshold instead of the default.

Приклад

Back
Clear

Код

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 the top_save param). It shows when the rows before the button weigh TOP_SAVE_MIN_ROWS (12) or more (a textarea 3, a rich editor 8, tabs their bar plus the longest tab); the asset yf_form_top_save hides 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