Coder Social home page Coder Social logo

bayareawebpro / laravel-multistep-forms Goto Github PK

View Code? Open in Web Editor NEW
89.0 8.0 11.0 91 KB

Responsable Multistep Form Builder for Laravel

License: MIT License

PHP 96.19% Blade 3.81%
laravel multistep-forms builder sessions validation forms laravel-multistep-forms multistep

laravel-multistep-forms's People

Contributors

bayareawebpro avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

laravel-multistep-forms's Issues

Elaborate on the documentations

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.

Can final logic be elsewhere than on the Form itself?

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!

Usage Question

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?

Values not saved unless validated

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

Saving Files

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.