bayareawebpro / laravel-multistep-forms Goto Github PK
View Code? Open in Web Editor NEWResponsable Multistep Form Builder for Laravel
License: MIT License
Responsable Multistep Form Builder for Laravel
License: MIT License
The class MultiStepForm
uses typed properties which only became available in PHP 7.4. As far as I can tell the composer.json
file states compatibility with php: ^7.1.3
.
Probably the easiest way to "fix" the issue is to change the compatibility.
Its hard to get your head around at first glance, the documentations doesnt specify where the examples given should be, whether in controller or a separate class. can you please save some time to work on the documentation step by step to make it easy for especially beginners.
Also from what i understand rendering and storing forms will be handled by same controller method so if you are using default laravel resources methods like index,create,store etc. you get errors with the route.
Well done with this package too it saves alot of time.
Hi there,
First, thank you for your work. It really helps.
It seems to me that the only way right now to do something when the form is finally submitted, is to add logic in the onStep
closure of the final step.
// CarRegistration.php
$form = Form::make($viewName, [
'title' => 'Car Registration',
])->namespaced('car_registration')
->canNavigateBack(true);
$form->addStep(1, Step1::make());
$form->addStep(2, Step2::make());
$form->addStep(3, Step3::make());
$form->onStep('*', function (Form $form) {
if ($form->request->get('submit') === 'reset') {
$form->reset();
}
});
$form->onStep($form->lastStep(), function (Form $form) {
$data = $form->toArray();
$form->reset();
Car::create([
'country' => $data['country'],
'brand' => $data['brand'],
'model' => $data['model'],
'year' => $data['year'],
]);
return redirect()->route('cars.index');
});
return $form;
I would like to have my logic in my controller (to avoid having logic in different places). Something like:
// CarRegistration.php
$form = Form::make($viewName, [
'title' => 'Car Registration',
])->namespaced('car_registration')
->canNavigateBack(true);
$form->addStep(1, Step1::make());
$form->addStep(2, Step2::make());
$form->addStep(3, Step3::make());
$form->onStep('*', function (Form $form) {
if ($form->request->get('submit') === 'reset') {
$form->reset();
}
});
return $form;
// CarRegistrationController.php
class CarRegistrationController extends Controller
{
public function form(): Form
{
$form = CarRegistration::make('car-registration');
if ($form->isOver()) {
$data = $form->toArray();
$form->reset();
Car::create([
'country' => $data['country'],
'brand' => $data['brand'],
'model' => $data['model'],
'year' => $data['year'],
]);
return redirect()->route('cars.index');
}
return $form;
}
}
Is something like this planned or already possible?
Thanks!
I may be missing something, but I'm not understanding which parts of your example go in the (Blade) view and which belong in the controller/model. Can you clarify?
Hi, first of all this package is really useful but also simple at the same time.
For optional fields, the values don't save to $form unless you validate it (with something like nullable). Is this intended?
Thanks
Hello! I have a file input on my form, and when i trying to save form result I have an error:
Serialization of 'Illuminate\Http\UploadedFile' is not allowed
My code:
<div class="card text-left mt-3"> <h6 class="card-header" style="font-size: 15px">Information</h6> <div class="card-body d-flex"> <div class="form-group w-75 mr-1"> <label for="requirements">Requirements</label> <div class="input-group mb-3"> <textarea name="requirements" class="editor">{{$form->getValue('requirements')}}</textarea> </div> </div> <div class="form-group w-25"> <label for="basic-url">Files</label> <input type="file" name="filefield" multiple="multiple"> </div> </div> </div>
->addStep(2, [ 'rules' => [ 'title' => 'required|string', 'requirements' => 'required', 'finish' => 'string', 'filefield' => 'nullable|mimes:jpg,jpeg,png', 'tags' => 'nullable|string' ], ])
How fix it?
step view passed through the configuration
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.