Skip to content

Commit 1d49061

Browse files
Add docs for time, date, repeater field
1 parent 16678f3 commit 1d49061

14 files changed

+154
-50
lines changed

docs/cms/form-builder-input-fields.md

+99-7
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,14 @@ The text input allows you to interact with a string:
88
use Botble\Base\Forms\Fields\TextField;
99
use Botble\Base\Forms\FieldOptions\TextFieldOption;
1010

11-
->add('name', TextField::class, TextFieldOption::make())
11+
$this
12+
->add('name', TextField::class, TextFieldOption::make());
1213
```
1314

15+
Result:
16+
17+
![Text Field](./images/form-text.png)
18+
1419
## Methods
1520

1621
```php
@@ -39,6 +44,11 @@ $this
3944
);
4045
```
4146

47+
::: info
48+
The same as other input fields, you can use the same methods as the text field.
49+
:::
50+
51+
4252
## Textarea Field
4353

4454
```php
@@ -48,6 +58,10 @@ use Botble\Base\Forms\FieldOptions\TextareaFieldOption;
4858
$this->add('description', TextareaField::class, TextareaFieldOption::make());
4959
```
5060

61+
Result:
62+
63+
![Textarea Field](./images/form-textarea.png)
64+
5165
## Number Field
5266

5367
```php
@@ -57,17 +71,95 @@ use Botble\Base\Forms\FieldOptions\NumberFieldOption;
5771
$this->add('limit', NumberField::class, NumberFieldOption::make());
5872
```
5973

74+
Result:
75+
76+
![Number Field](./images/form-number.png)
77+
78+
## Number field with jQuery input mask
79+
80+
```php
81+
use Botble\Base\Facades\Assets;
82+
use Botble\Base\Forms\Fields\TextField;
83+
use Botble\Member\Forms\Fronts\Auth\FieldOptions\TextFieldOption;
84+
85+
public function setup(): void
86+
{
87+
Assets::addScripts(['input-mask']); // add jQuery input mask
88+
89+
$this->add(
90+
'price',
91+
TextField::class, // Must be a text field, not number field
92+
TextFieldOption::make()
93+
->addAttribute('class', 'form-control input-mask-number')
94+
);
95+
}
96+
```
97+
98+
Result:
99+
100+
![Input mask number Field](./images/form-input-mask-number.png)
101+
60102
## Password Field
61103

62104
```php
63105
use Botble\Base\Forms\Fields\PasswordField;
64-
use Botble\Base\Forms\FieldOptions\PasswordFieldOption;
106+
use Botble\Base\Forms\FieldOptions\TextFieldOption;
65107

66-
$this->add('password', PasswordField::class, PasswordFieldOption::make());
108+
$this->add('password', PasswordField::class, TextFieldOption::make());
67109
```
68110

69-
::: info
70-
The same as other input fields, you can use the same methods as the text field.
71-
:::
111+
Result:
112+
113+
![Password Field](./images/form-password.png)
114+
115+
## Color Field
116+
117+
```php
118+
use Botble\Base\Forms\Fields\ColorField;
119+
use Botble\Base\Forms\FieldOptions\ColorFieldOption;
120+
121+
$this->add('color', ColorField::class, ColorFieldOption::make());
122+
```
123+
124+
Result:
125+
126+
![Color Field](./images/form-color.png)
127+
128+
## Time Field
129+
130+
```php
131+
use Botble\Base\Forms\Fields\TimeField;
132+
use Botble\Base\Forms\FieldOptions\TextFieldOption;
133+
134+
$this->add('time', TimeField::class, TextFieldOption::make());
135+
```
136+
137+
Result:
138+
139+
![Time Field](./images/form-time.png)
140+
141+
## Time field with jquery time picker
142+
143+
```php
144+
use Botble\Base\Forms\Fields\TimePickerField;
145+
use Botble\Base\Forms\FieldOptions\TextFieldOption;
146+
147+
$this->add('time', TimePickerField::class, TextFieldOption::make());
148+
```
149+
150+
Result:
151+
152+
![Timepicker Field](./images/form-time-picker.png)
153+
154+
## Date picker field
155+
156+
```php
157+
use Botble\Base\Forms\Fields\DatePickerField;
158+
use Botble\Base\Forms\FieldOptions\DatePickerFieldOption;
159+
160+
$this->add('date', DatePickerField::class, DatePickerFieldOption::make());
161+
```
162+
163+
Result:
72164

73-
...
165+
![Datepicker Field](./images/form-date-picker.png)
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Repeater Field
2+
3+
```php
4+
5+
use Botble\Base\Forms\FieldOptions\RepeaterFieldOption;
6+
use Botble\Base\Forms\Fields\RepeaterField;
7+
8+
$this
9+
->add(
10+
'example_fields',
11+
RepeaterField::class,
12+
RepeaterFieldOption::make()
13+
->label('Example fields')
14+
->fields([
15+
'name' => [ // Requires index key
16+
'type' => 'text',
17+
'label' => 'Name',
18+
'attributes' => [
19+
'name' => 'name',
20+
'value' => null,
21+
'options' => [
22+
'class' => 'form-control',
23+
'data-counter' => 255,
24+
],
25+
],
26+
],
27+
'description' => [
28+
'type' => 'textarea',
29+
'label' => 'Description',
30+
'attributes' => [
31+
'name' => 'description',
32+
'value' => null,
33+
'options' => [
34+
'class' => 'form-control',
35+
'rows' => 4,
36+
],
37+
],
38+
],
39+
'image' => [
40+
'type' => 'mediaImage',
41+
'label' => 'Image',
42+
'attributes' => [
43+
'name' => 'image',
44+
'value' => null,
45+
],
46+
],
47+
])
48+
);
49+
50+
```
51+
52+
Result:
53+
54+
![Repeater Field](./images/form-repeater.png)

docs/cms/form-builder.md

-43
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,3 @@
1-
### Color field
2-
3-
```php
4-
->add('field_name', 'color', [
5-
'label' => __('Field label'),
6-
'label_attr' => ['class' => 'control-label'],
7-
])
8-
```
9-
10-
### Time field
11-
12-
```php
13-
->add('field_name', 'time', [
14-
'label' => __('Field label'),
15-
'label_attr' => ['class' => 'control-label'],
16-
])
17-
```
18-
19-
### Number field with input mask
20-
21-
```php
22-
Assets::addScripts(['input-mask']);
23-
24-
->add('field_name', 'text', [
25-
'label' => __('Field label'),
26-
'label_attr' => ['class' => 'control-label'],
27-
'attr' => [
28-
'id' => 'field_name',
29-
'class' => 'form-control input-mask-number',
30-
],
31-
])
32-
```
33-
34-
### Date picker field
35-
36-
```php
37-
->add('field_name', 'datePicker', [
38-
'label' => __('Field label'),
39-
'label_attr' => ['class' => 'control-label'],
40-
'default_value' => now(config('app.timezone'))->format('Y/m/d'),
41-
])
42-
```
43-
441
### Repeater fields
452

463
```php

docs/cms/images/form-color.png

161 KB
Loading

docs/cms/images/form-date-picker.png

105 KB
Loading
34 KB
Loading

docs/cms/images/form-number.png

23.4 KB
Loading

docs/cms/images/form-password.png

32.4 KB
Loading

docs/cms/images/form-repeater.png

125 KB
Loading

docs/cms/images/form-text.png

24 KB
Loading

docs/cms/images/form-textarea.png

47.4 KB
Loading

docs/cms/images/form-time-picker.png

43.2 KB
Loading

docs/cms/images/form-time.png

166 KB
Loading

docs/cms/sidebar.ts

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export default [
6767
{ text: 'Select Field', link: '/cms/form-builder-select-field' },
6868
{ text: 'On/off Field', link: '/cms/form-builder-on-off-field' },
6969
{ text: 'Radio Field', link: '/cms/form-builder-radio-field' },
70+
{ text: 'Repeater Field', link: '/cms/form-builder-repeater-field' },
7071
{ text: 'Media Image Field', link: '/cms/form-builder-media-image-field' },
7172
],
7273
},

0 commit comments

Comments
 (0)