PHP code example of rinodrummer / livewire-wizard-form
1. Go to this page and download the library: Download rinodrummer/livewire-wizard-form 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/ */
rinodrummer / livewire-wizard-form example snippets
namespace App\Livewire;
use Livewire\Component;
use LivewireWizardForm\Wizard\IsWizard;
use LivewireWizardForm\Wizard\Contracts\WizardComponent;
class CreateUserWizard extends Component implements WizardComponent {
use IsWizard;
public function steps(): array {
return [
// List of the step identifiers
];
}
}
namespace App\Livewire;
use Livewire\Component;
use App\Enums\CreateUserStep;
use LivewireWizardForm\Wizard\IsWizard;
use LivewireWizardForm\Wizard\Contracts\WizardComponent;
/**
* @implements WizardComponent<CreateUserStep>
* @uses IsWizard<CreateUserStep>
*/
class CreateUserWizard extends Component implements WizardComponent {
use IsWizard;
public function useEnum(): ?string {
return CreateUserStep::class;
}
public function steps(): array {
return CreateUserStep::cases();
}
}
public function currentStepComponent(): string
{
$component = match ($this->currentStep()) {
CreateUserStep::Profile => UserProfileStep::class,
CreateUserStep::Contacts => UserContactsStep::class,
CreateUserStep::Avatar => UserAvatarStep::class,
CreateUserStep::Preferencies => UserPreferenciesStep::class,
};
// Uses Livewire's component name resolution to retrieve the component name
return resolve(Livewire\Mechanisms\ComponentRegistry::class)
->getName($component);
}
use Livewire\Component;
use LivewireWizardForm\Wizard\IsStep;
use LivewireWizardForm\Wizard\Contracts\StepComponent;
class UserProfileStep extends Component implements StepComponent
{
use IsStep;
[StepStateProperty]
public array $data = [
'username' => '',
'email' => '',
'first_name' => '',
'last_name' => '',
];
public function render()
{
return view('livewire.user-profile-step');
}
}
use Livewire\Component;
use LivewireWizardForm\Wizard\IsStep;
use App\Livewire\Forms\UserProfileForm;
use LivewireWizardForm\Wizard\Contracts\StepComponent;
class UserProfileStep extends Component implements StepComponent
{
use IsStep;
[StepStateProperty]
public UserProfileForm $form;
public function render()
{
return view('livewire.user-profile-step');
}
}
public function previousStep(bool $quietly = false): void;
public function nextStep(bool $quietly = false): void;
// Submits the wizard
public function submitWizard(): void;
// Submits the wizard if no other steps are defined, otherwise goes to the next one
public function proceedWithWizard(bool $quietly = false): bool;
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.