PHP code example of bayareawebpro / laravel-multistep-forms
1. Go to this page and download the library: Download bayareawebpro/laravel-multistep-forms library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
bayareawebpro / laravel-multistep-forms example snippets
use BayAreaWebPro\MultiStepForms\MultiStepForm;
// Render a view with data.
return Form::make('my-form', [
'title' => 'MultiStep Form'
])
// Namespace the session data.
->namespaced('my-session-key')
// Allow backwards navigation via get request. ?form_step=x
->canNavigateBack(true)
// Tap invokable Class __invoke(Form $form)
->tap(new InvokableClass)
// Before x step validation...
->beforeStep(1, function (MultiStepForm $form) {
// Maybe return early or redirect?
})
// Before all step validation...
->beforeStep('*', function (MultiStepForm $form) {
// Maybe return early or redirect?
})
// Validate Step 1
->addStep(1, [
'rules' => ['name' => 'cts to paths, array data etc...
return $data;
})
// Modify data before saved to session after each step.
->onComplete(function(MultiStepForm $form) {
// Final submission logic.
})
;
use BayAreaWebPro\MultiStepForms\MultiStepForm;
$form = MultiStepForm::make('onboarding.start', [
'title' => 'Setup your account'
]);
$form->namespaced('onboarding');
$form->canNavigateBack(true);
$form->addStep(2, [
'rules' => [
'role' => 'Your name is ],
])
use BayAreaWebPro\MultiStepForms\MultiStepForm;
class ProfileStep
{
public function __construct(private int $step)
{
//
}
public function __invoke(MultiStepForm $form)
{
$form->addStep($this->step, [
'rules' => [
'name' => '
// Boolean Usage
$form->isPast(2): bool
$form->isActive(2): bool
$form->isFuture(2): bool
// Usage as HTML Class Helpers
$form->isPast(2, 'truthy-class', 'falsy-class'): string
$form->isActive(2, 'truthy-class', 'falsy-class'): string
$form->isFuture(2, 'truthy-class', 'falsy-class'): string
use BayAreaWebPro\MultiStepForms\MultiStepForm as Form;
$form = Form::make('my-view', $data);
$form->namespaced('onboarding');
$form->canNavigateBack(true);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.