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

form() довідник

56 записів для 138 методи. Кожен запис виконує свій приклад на цій сторінці й показує його код.

Form

array_to_form()Build the fields from an array of [method, name, desc or options, ...] rows, e.g. a form kept in a config file.
auto()Build a form from the columns of a DB table and fill it with one row: the field kind follows the column type.
form($replace, $params)Start a form from the values to show ($replace) and its options ($params); it renders when printed or on render().
tpl_row()One form row from a template: the {form_row("text","login","Login")} tag of the template engine calls it.

Layout

container()A form row holding any HTML you give (a table, a widget, a text), with the label of the row.
custom_fields()Edit free-form attributes kept in one text field (key=value;key=value) as one input per key.
fieldset_start(), fieldset_end()Group fields in a fieldset with a legend; a new fieldset_start() closes the previous one.
form_begin(), form_end()The opening and closing form tags with their first fieldset; render() adds them itself unless you place them.
func()A form row rendered by your callback, which gets the options, the values and the form.
row_start(), row_end()Put several fields in one form row under one label (stacked row), e.g. a phone code and number.
tab_start(), tab_end()Split a long form into tabs: fields between tab_start() and tab_end() go into one tab of html()->tabs().

Text inputs

email(), login()An email field (type email, @ icon) and a login field (text, user icon), with the usual default names.
file(), image()A file input; the form becomes multipart/form-data. image() is the same with the default name image.
hidden()A hidden input with the value from $replace (or the value option); no row is drawn.
HTML5 inputsinput() with an HTML5 type and a default name: url, color, date, datetime, datetime-local, month, range, search, tel, time, week.
input()A form row with an <input> of any type; text(), email(), number() and the other inputs are input() with a type.
number(), integer(), float(), decimal(), money(), price()Number fields: number() / integer() whole numbers, float() / decimal() step 0.01, money() with a currency sign, price() also min 0.
password()A password field with a key icon; it never shows a value from $replace unless you pass value.
Rich text editors: TinyMCE and CKEditorWhich rich text editor a form2 textarea can have, how to turn each one on, and how they follow Bootstrap 3, 5 and the dark mode.
text()A one-line text field: input() with type text.
textarea()A multi-line text field; the value is escaped, a rich editor can replace it.
tinymce()A textarea with the TinyMCE 8 rich text editor; without JavaScript it stays a plain textarea.

Choices

active_box(), allow_deny_box(), yes_no_box()Two-state radios for a 0 / 1 field: Active / Inactive, Allow / Deny, Yes / No.
button_radio_box(), button_check_box(), button_yes_no_box()Radios and check boxes drawn as a group of toggle buttons; button_yes_no_box() is the Yes / No pair.
check_box(), switch_box(), multi_check_box()A single check box (switch_box(): a Bootstrap 5 switch) or a group of check boxes posting name[] (multi_check_box()).
div_box(), list_box(), button_box(), button_split_box()Choices as a Bootstrap dropdown with a hidden input: div_box(), list_box() (bfh-selectbox), button_box(), button_split_box().
order_box()Ascending / Descending radios, for the sort direction of a filter form.
radio_box()A group of radio buttons, one value of value => label pairs.
select_box(), multi_select(), multi_select_box()A drop-down of value => text pairs; multi_select() / multi_select_box() allow several values (name[]).

Pickers and widgets

captcha()A captcha image with its input; the field is required and checked by the captcha validation rule.
date_box(), time_box(), datetime_box(), birth_box()Dates and times as groups of select boxes (day, month, year, hour...) that work without JavaScript.
daterange(), daterange_select()One field for a date range (bootstrap-daterangepicker), as the admin filters use it; daterange() is the alias.
datetime_select()A date and / or time picker field: eonasdan (default; Tempus Dominus on Bootstrap 5), native inputs, flatpickr or Tempus Dominus, with limits and a format.
google_maps()A Google map to place up to N markers; their coordinates post in a field.
image_select_box()Pick one image from a list of thumbnails (jQuery image picker); posts the value of the picked image.
map_select()Pick one point on a map (maps plugin): latitude and longitude inputs filled by a click or a dragged marker; they post plain numbers.
phone_box()A phone field with a country flag picker and a formatted number (intl-tel-input), checked in the browser by formvalidation.
select2_box(), chosen_box()A searchable select on jQuery: Select2 3.5 (select2_box()) or Chosen 1.7 (chosen_box()); new code uses tom_select_box().
stars(), stars_select()A rating: stars() shows the value as stars, stars_select() lets the visitor pick one with radio stars.
tom_select_box(), tags_box()Select with search, groups, several values or a remote search (tom_select_box()), and free tags in one field (tags_box()), on Tom Select without jQuery.
ui_range()A jQuery UI slider for one value or a range, with hidden inputs that post the values.
upload()A multi-file upload widget (blueimp jQuery File Upload) from the form2/upload template.
user_select_box()A Select2 field that searches the site users through the form API endpoint; shows login and id.

Ready-made boxes

Geo and locale boxesReady selects of countries, regions, cities, currencies, locales, languages and time zones from the framework data.
icon_select_box()Pick a Font Awesome icon from the full list, each shown with its icon.
Method, template and location boxesAdmin pickers of a module method (object.action), a template, or a location, for the user or the admin side.

Display rows

box(), box_with_link()A row that prints ready HTML from $replace[name] (a box built elsewhere), with an optional edit link.
info(), info_date(), info_link(), info_lang()Read-only rows: a value as a label (info()), a formatted date (info_date()), a link (info_link()), a language with its flag (info_lang()).
user_info(), admin_info()Read-only rows naming the user (or admin) of $replace[user_id], linked to the account page.

Buttons and links

button()An <input type="button"> in a form row, for scripts (it does not submit).
link()A link button in a form row (Cancel, Back, Help), the text from the first argument.
submit(), save(), save_and_back(), save_and_clear(), preview()Submit buttons: submit(), save() with an icon, save_and_back() / save_and_clear() with a Back / Clear link, preview().
tbl_link(), tbl_link_add(), tbl_link_edit(), tbl_link_delete(), tbl_link_clone(), tbl_link_view(), tbl_link_active()Small row-action links for item templates (category or menu editors): add, edit, delete, clone, view, active.

Validation and saving

db_insert_if_ok(), insert_if_ok(), db_update_if_ok(), update_if_ok(), change_if_ok()After a valid POST, insert or update a DB row from the validated fields, then show a notice and redirect.
Events: on_post() ... on_after_update()Callbacks at each step of a form: POST, render, validation, the DB write and the success notice.
validate()Server-side validation of the posted form: rules per field, errors shown on the fields, the cleaned values for saving.

Демо