laravel-form

Versie
7.3.1
Downloads
8.608 downloads
Licentie
MIT
GitHub

API Reference

Form Builder Methods

Form Control Methods

Method Description
open($options) Open a new HTML form. Options: url, route, action, method, files
model($model, $options) Create a model-based form with automatic value binding
close() Close the current form and reset model binding
token() Generate CSRF token hidden field
getModel() Get the current model instance
setModel($model) Set the model instance for value binding

Input Elements

Method Description
label($name, $value, $options, $escape) Generate a label element
input($type, $name, $value, $options) Generate a generic input element
text($name, $value, $options) Generate a text input
email($name, $value, $options) Generate an email input
password($name, $options) Generate a password input (never fills value)
url($name, $value, $options) Generate a URL input
tel($name, $value, $options) Generate a telephone input
number($name, $value, $options) Generate a number input
search($name, $value, $options) Generate a search input
range($name, $value, $options) Generate a range slider input
hidden($name, $value, $options) Generate a hidden input
file($name, $options) Generate a file upload input
color($name, $value, $options) Generate a color picker input

Date & Time Inputs

Method Description
date($name, $value, $options) Generate a date input (accepts DateTime objects)
datetime($name, $value, $options) Generate a datetime input (accepts DateTime objects)
datetimeLocal($name, $value, $options) Generate a datetime-local input (accepts DateTime objects)
time($name, $value, $options) Generate a time input (accepts DateTime objects)
month($name, $value, $options) Generate a month input (accepts DateTime objects)
week($name, $value, $options) Generate a week input (accepts DateTime objects)

Selection & Choice Elements

Method Description
select($name, $list, $selected, $selectAttributes, $optionsAttributes, $optgroupsAttributes) Generate a select dropdown with advanced option control
selectRange($name, $begin, $end, $selected, $options) Generate a select with numeric range
selectYear($name, $begin, $end, $selected, $options) Alias for selectRange (for year selection)
selectMonth($name, $selected, $options, $format) Generate a select with localized month names
datalist($id, $list) Generate an HTML5 datalist element for autocomplete
checkbox($name, $value, $checked, $options) Generate a checkbox input
radio($name, $value, $checked, $options) Generate a radio button input

Buttons

Method Description
submit($value, $options) Generate a submit button
button($value, $options) Generate a button element
reset($value, $options) Generate a reset button
image($url, $name, $options) Generate an image submit button

Textarea

Method Description
textarea($name, $value, $options) Generate a textarea. Supports size option (e.g., '50x10')

Value Resolution

Method Description
getValueAttribute($name, $value) Get the value for a field (respects priority: old input → request → explicit → model)
old($name) Retrieve old input from session
considerRequest($consider) Enable/disable using current request for default values

Session Management

Method Description
getSessionStore() Get the current session store instance
setSessionStore($session) Set a custom session store instance

HTML Builder Methods

Method Description
link($url, $title, $attributes, $secure, $escape) Generate an HTML link
secureLink($url, $title, $attributes, $escape) Generate a secure HTTPS link
linkAsset($url, $title, $attributes, $secure, $escape) Generate a link to an asset file
linkSecureAsset($url, $title, $attributes, $escape) Generate a secure HTTPS link to an asset
linkRoute($name, $title, $parameters, $attributes, $secure, $escape) Generate a link to a named route
linkAction($action, $title, $parameters, $attributes, $secure, $escape) Generate a link to a controller action
mailto($email, $title, $attributes, $escape) Generate an obfuscated mailto link (anti-spam)

Assets

Method Description
script($url, $attributes, $secure) Generate a script tag. Supports attributes like defer, async
style($url, $attributes, $secure) Generate a stylesheet link. Supports media attribute
image($url, $alt, $attributes, $secure) Generate an image tag
favicon($url, $attributes, $secure) Generate a favicon link tag

Lists

Method Description
ol($list, $attributes) Generate an ordered list (supports nested arrays)
ul($list, $attributes) Generate an unordered list (supports nested arrays)
dl($list, $attributes) Generate a definition list

Meta & Generic Tags

Method Description
meta($name, $content, $attributes) Generate a meta tag
tag($tag, $content, $attributes) Generate any HTML tag with content

Utility Methods

Method Description
entities($value) Convert string to HTML entities (XSS protection)
decode($value) Convert HTML entities back to characters
email($email) Obfuscate an email address (returns string, not link)
obfuscate($value) Obfuscate any string to prevent spam bot harvesting
nbsp($num) Generate non-breaking space entities ( )
attributes($attributes) Build an HTML attribute string from an array

Een fout gevonden of een vraag? Maak een issue aan op GitHub.