Skip to content

Commit 0350486

Browse files
committed
fix: Instruction
1 parent 524104b commit 0350486

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

README.md

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,91 @@ ButtonGroup::make('Plan')->options([
188188
3 => 'Pro',
189189
])->multiple(),
190190
```
191+
192+
## Example
193+
194+
```php
195+
public function stepForm(MoonShineRequest $request): MoonShineJsonResponse
196+
{
197+
$request->validate([
198+
'name' => ['required'],
199+
'email' => ['required'],
200+
]);
201+
202+
return MoonShineJsonResponse::make()->events([
203+
'go_to_step_2:dashboard'
204+
]);
205+
}
206+
207+
protected function components(): iterable
208+
{
209+
return [
210+
Stepper::make([
211+
Step::make([
212+
FormBuilder::make()
213+
->name('step_1_form')
214+
->asyncMethod('stepForm')
215+
->fields([
216+
Grid::make([
217+
Column::make([
218+
Box::make([
219+
Text::make('Name'),
220+
Email::make('Email'),
221+
222+
RadioGroup::make('Sex')->options([
223+
1 => 'Male',
224+
2 => 'Female',
225+
])->inline(),
226+
])
227+
])->columnSpan(6),
228+
229+
Column::make([
230+
Box::make([
231+
CheckboxList::make('Job title')->options([
232+
1 => 'Developer',
233+
2 => 'Team lead',
234+
]),
235+
236+
ButtonGroup::make('Plan')->options([
237+
1 => 'Free',
238+
2 => 'Basic',
239+
3 => 'Pro',
240+
]),
241+
])
242+
])->columnSpan(6)
243+
])
244+
])
245+
->hideSubmit()
246+
], 'Step 1', 'Tell us about yourself')->nextLock()->whenFinishEvents([
247+
AlpineJs::event(JsEvent::FORM_SUBMIT, 'step_1_form')
248+
]),
249+
Step::make([
250+
AsyncTabs::make([
251+
AsyncTab::make('How to use the project', '/html'),
252+
AsyncTab::make('User agreement', '/html'),
253+
]),
254+
], 'Step 2', 'Rules')->icon('users'),
255+
256+
Step::make([], 'Step 3', 'Finishing')->async('/html', events: [
257+
AlpineJs::event(JsEvent::FRAGMENT_UPDATED, '_content1')
258+
])->whenFinishEvents([
259+
AlpineJs::event(JsEvent::FRAGMENT_UPDATED, '_content2')
260+
]),
261+
], [
262+
Heading::make('Thanks!'),
263+
LinkGroup::make([
264+
LinkItem::make('#', 'Link 1', 'Description 1')->icon('arrow-right'),
265+
LinkItem::make('#', 'Link 2'),
266+
])
267+
], 'Next', 'Finish')->name('dashboard')->lock(),
268+
269+
Fragment::make([
270+
time()
271+
])->name('_content1'),
272+
273+
Fragment::make([
274+
time()
275+
])->name('_content2'),
276+
];
277+
}
278+
```

0 commit comments

Comments
 (0)