Skip to content

Commit 3187ba5

Browse files
committed
Document new "url" field
1 parent 9347f8e commit 3187ba5

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

backend/forms.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,45 @@ blog_contents:
681681
size: large
682682
```
683683

684+
### URL
685+
686+
`url` – renders a single-line input for URL values with built-in browser validation.
687+
688+
```yaml
689+
website:
690+
label: Website
691+
type: url
692+
placeholder: https://example.com
693+
required: true
694+
maxlength: 2048
695+
pattern: https://.*
696+
size: 50
697+
options:
698+
https://wintercms.com: Winter CMS
699+
https://laravel.com: Laravel
700+
```
701+
702+
- Displays a link icon on the left in both edit and preview modes.
703+
- In preview mode, renders as a clickable link that opens in a new tab.
704+
- Supports all standard HTML5 attributes for `<input type="url">`:
705+
- `placeholder`, `maxlength`, `minlength`, `pattern`, `size`, `list`, `autocomplete`, `required`, `readonly`, `disabled`
706+
- `options` will be rendered in a `<datalist>` element, enabling autocomplete suggestions.
707+
- If an option's value and label are identical, the label is omitted for brevity.
708+
709+
See [Defining field options](#defining-field-options) for the different methods to specify the options.
710+
711+
#### Server-side validation
712+
713+
To validate this field on save, define a validation rule in your model:
714+
715+
```php
716+
public $rules = [
717+
'website' => 'nullable|url|max:2048',
718+
];
719+
```
720+
721+
> **Tip:** Use `nullable` if the field is not required but must still be a valid URL when provided.
722+
684723
### Widget
685724

686725
`widget` - renders a custom form widget, the `type` field can refer directly to the class name of the widget or the registered alias name.
@@ -950,7 +989,7 @@ Option | Description
950989

951990
> **NOTE:** Unlike the [Media Finder FormWidget](#media-finder), the File Upload FormWidget uses [database file attachments](../database/attachments); so the field name must match a valid `attachOne` or `attachMany` relationship on the Model associated with the Form. **IMPORTANT:** Having a database column with the name used by this field type (i.e. a database column with the name of an existing `attachOne` or `attachMany` relationship) **will** cause this FormWidget to break. Use database columns with the Media Finder FormWidget and file attachment relationships with the File Upload FormWidget.
952991

953-
By default, the File Upload FormWidget only allows a limited set of file extensions. You can extend this list by adding a `fileDefinitions` config in `config/cms.php` file.
992+
By default, the File Upload FormWidget only allows a limited set of file extensions. You can extend this list by adding a `fileDefinitions` config in `config/cms.php` file.
954993
See [Allowed file types](../setup/configuration#allowed-file-types) for more information.
955994

956995
### Icon Picker

0 commit comments

Comments
 (0)