New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nova Form Tool Package #63

Open
dillingham opened this Issue Dec 30, 2018 · 2 comments

Comments

Projects
None yet
1 participant
@dillingham
Copy link
Collaborator

dillingham commented Dec 30, 2018

Package that renders a form and allows the use of nova fields, panel display, and instead passes to a controller of your choosing. These should look identical to nova create, should validate the same way and renders all inputs, including belongsto/searchable & custom fields

NovaServiceProvider tools()
NovaForm(‘App\Nova\Forms\SupportController’)
  • get request: create() for the fields and page title
  • post request store() when form submits
@dillingham

This comment has been minimized.

Copy link
Collaborator

dillingham commented Dec 30, 2018

<?php

namespace App\Nova\Forms;

use Illuminate\Http\Request;
use Laravel\Nova\Fields\Text;

use NovaForm\NovaFormController;

class Support extends NovaFormController
{
    function __construct()
    {
        $this->authorize();
    }

    function create()
    {
        return [
            Text::make('Name')
                ->rules('required', 'max:255'),

            Text::make('Email')
                ->rules('required', 'email', 'max:254')
        ];
    }

    public function store(Request $request)
    {
        \\ call some 3rd party service to process support request

        return response()->json([
            'redirect' => back(),
            'message' => 'We will get back to you soon!',
            'delay' => 2000,
        ]);
    }
}
@dillingham

This comment has been minimized.

Copy link
Collaborator

dillingham commented Dec 30, 2018

Some how registering this dynamically & allowing other package developers to do the same 🔥

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment