form_begin(), form_end() form()

The opening and closing form tags with their first fieldset; render() adds them itself unless you place them.

form()->form_begin($name = '', $method = '', $extra = [], $replace = [])
form()->form_end($extra = [], $replace = [])

Options

OptionMeaning
$name, $methodForm name (default form_action, also the $replace key of its action) and method (default post).
action, class, class_add, id, style, target, enctype, for_upload, novalidate, autocompleteAttributes of <form>.
fieldset, legendAttributes of the first <fieldset>; its legend.

Example

Search

Code

return form([], ['no_form' => 1])
    ->form_begin('search', 'get', ['class' => 'form-inline', 'legend' => 'Search'])
    ->search('q', ['placeholder' => 'Find a product'])
    ->submit(['value' => 'Search'])
    ->form_end();

Notes

  • Outside the chain (_class('form2')->form_begin()) they return the HTML at once.
  • On the user side a relative action goes through process_url().

See also: form/form, form/fieldset