Code Monkey home page Code Monkey logo

laravel-form-builder's Introduction

Build Status Coverage Status Total Downloads Latest Stable Version License

Laravel 5 form builder

Join the chat at https://gitter.im/kristijanhusak/laravel-form-builder

Form builder for Laravel 5 inspired by Symfony's form builder. With help of Laravels FormBuilder class creates forms that can be easy modified and reused. By default it supports Bootstrap 3.

Laravel 4

For Laravel 4 version check laravel4-form-builder.

Bootstrap 4 support

To use bootstrap 4 instead of bootstrap 3, install laravel-form-builder-bs4.

Upgrade to 1.6

If you upgraded to >1.6.* from 1.5.* or earlier, and having problems with form value binding, rename default_value to value.

More info in changelog.

Documentation

For detailed documentation refer to https://kristijanhusak.github.io/laravel-form-builder/.

Changelog

Changelog can be found here.

Installation

Using Composer

composer require kris/laravel-form-builder

Or manually by modifying composer.json file:

{
    "require": {
        "kris/laravel-form-builder": "1.*"
    }
}

And run composer install

Then add Service provider to config/app.php

    'providers' => [
        // ...
        Kris\LaravelFormBuilder\FormBuilderServiceProvider::class
    ]

And Facade (also in config/app.php)

    'aliases' => [
        // ...
        'FormBuilder' => Kris\LaravelFormBuilder\Facades\FormBuilder::class
    ]

Notice: This package will add laravelcollective/html package and load aliases (Form, Html) if they do not exist in the IoC container.

Quick start

Creating form classes is easy. With a simple artisan command:

php artisan make:form Forms/SongForm --fields="name:text, lyrics:textarea, publish:checkbox"

Form is created in path app/Forms/SongForm.php with content:

<?php

namespace App\Forms;

use Kris\LaravelFormBuilder\Form;
use Kris\LaravelFormBuilder\Field;

class SongForm extends Form
{
    public function buildForm()
    {
        $this
            ->add('name', Field::TEXT, [
                'rules' => 'required|min:5'
            ])
            ->add('lyrics', Field::TEXTAREA, [
                'rules' => 'max:5000'
            ])
            ->add('publish', Field::CHECKBOX);
    }
}

If you want to instantiate empty form without any fields, just skip passing --fields parameter:

php artisan make:form Forms/PostForm

Gives:

<?php

namespace App\Forms;

use Kris\LaravelFormBuilder\Form;

class PostForm extends Form
{
    public function buildForm()
    {
        // Add fields here...
    }
}

After that instantiate the class in the controller and pass it to view:

<?php

namespace App\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
use Kris\LaravelFormBuilder\FormBuilder;

class SongsController extends BaseController {

    public function create(FormBuilder $formBuilder)
    {
        $form = $formBuilder->create(\App\Forms\SongForm::class, [
            'method' => 'POST',
            'url' => route('song.store')
        ]);

        return view('song.create', compact('form'));
    }

    public function store(FormBuilder $formBuilder)
    {
        $form = $formBuilder->create(\App\Forms\SongForm::class);

        if (!$form->isValid()) {
            return redirect()->back()->withErrors($form->getErrors())->withInput();
        }

        // Do saving and other things...
    }
}

Alternative example:

<?php

namespace App\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
use Kris\LaravelFormBuilder\FormBuilder;
use App\Forms\SongForm;

class SongsController extends BaseController {

    public function create(FormBuilder $formBuilder)
    {
        $form = $formBuilder->create(SongForm::class, [
            'method' => 'POST',
            'url' => route('song.store')
        ]);

        return view('song.create', compact('form'));
    }

    public function store(FormBuilder $formBuilder)
    {
        $form = $formBuilder->create(SongForm::class);

        if (!$form->isValid()) {
            return redirect()->back()->withErrors($form->getErrors())->withInput();
        }

        // Do saving and other things...
    }
}

If you want to store a model after a form submit considerating all fields are model properties:

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Kris\LaravelFormBuilder\FormBuilder;
use App\SongForm;

class SongFormController extends Controller
{
    public function store(FormBuilder $formBuilder)
    {
        $form = $formBuilder->create(\App\Forms\SongForm::class);
        $form->redirectIfNotValid();
        
        SongForm::create($form->getFieldValues());

        // Do redirecting...
    }

You can only save properties you need:

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Kris\LaravelFormBuilder\FormBuilder;
use App\SongForm;

class SongFormController extends Controller
{
    public function store(FormBuilder $formBuilder, Request $request)
    {
        $form = $formBuilder->create(\App\Forms\SongForm::class);
        $form->redirectIfNotValid();
        
        $songForm = new SongForm();
        $songForm->fill($request->only(['name', 'artist'])->save();

        // Do redirecting...
    }

Or you can update any model after form submit:

<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use Kris\LaravelFormBuilder\FormBuilder;
use App\SongForm;

class SongFormController extends Controller
{
    public function update(int $id, Request $request)
    {
        $songForm = SongForm::findOrFail($id);

        $form = $this->getForm($songForm);
        $form->redirectIfNotValid();

        $songForm->update($form->getFieldValues());

        // Do redirecting...
    }

Create the routes

// app/Http/routes.php
Route::get('songs/create', [
    'uses' => 'SongsController@create',
    'as' => 'song.create'
]);

Route::post('songs', [
    'uses' => 'SongsController@store',
    'as' => 'song.store'
]);

Print the form in view with form() helper function:

<!-- resources/views/song/create.blade.php -->

@extends('app')

@section('content')
    {!! form($form) !!}
@endsection

Go to /songs/create; above code will generate this html:

<form method="POST" action="http://example.dev/songs">
    <input name="_token" type="hidden" value="FaHZmwcnaOeaJzVdyp4Ml8B6l1N1DLUDsZmsjRFL">
    <div class="form-group">
        <label for="name" class="control-label">Name</label>
        <input type="text" class="form-control" id="name">
    </div>
    <div class="form-group">
        <label for="lyrics" class="control-label">Lyrics</label>
        <textarea name="lyrics" class="form-control" id="lyrics"></textarea>
    </div>
    <div class="form-group">
        <label for="publish" class="control-label">Publish</label>
        <input type="checkbox" name="publish" id="publish">
    </div>
</form>

Or you can generate forms easier by using simple array

<?php

namespace App\Http\Controllers;

use Illuminate\Routing\Controller as BaseController;
use Kris\LaravelFormBuilder\FormBuilder;
use Kris\LaravelFormBuilder\Field;
use App\Forms\SongForm;

class SongsController extends BaseController {

    public function create(FormBuilder $formBuilder)
    {
        $form = $formBuilder->createByArray([
                        [
                            'name' => 'name',
                            'type' => Field::TEXT,
                        ],
                        [
                            'name' => 'lyrics',
                            'type' => Field::TEXTAREA,
                        ],
                        [
                            'name' => 'publish',
                            'type' => Field::CHECKBOX
                        ],
                    ]
            ,[
            'method' => 'POST',
            'url' => route('song.store')
        ]);

        return view('song.create', compact('form'));
    }
}

Contributing

Project follows PSR-2 standard and it's covered with PHPUnit tests. Pull requests should include tests and pass Travis CI build.

To run tests first install dependencies with composer install.

After that tests can be run with vendor/bin/phpunit

laravel-form-builder's People

Contributors

azisyus avatar beghelli avatar cweiske avatar eloar avatar fourstacks avatar koenvu avatar koichirose avatar kristijanhusak avatar marcoraddatz avatar max-kovpak avatar mikeerickson avatar n7olkachev avatar nea avatar noxify avatar obrunsmann avatar pimlie avatar rudiedirkx avatar saeidraei avatar salkhwlani avatar sandermuller avatar sangnguyenplus avatar schursin avatar scrutinizer-auto-fixer avatar stefanprintezis avatar ukeloop avatar unckleg avatar weeblewonder avatar wuwx avatar yaquawa avatar yarbsemaj 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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

laravel-form-builder's Issues

Robust way to pass labels to validator

Hello,

I am playing now with the lib. so far very good impressions.
But I can't find on how to link validation labels with labels from this package...

so for example I have this:

            $this
                ->add('pkg', 'text', [
                    'label' => trans('setting.package_label')
                ])

On the form, I see correct Label, but when getting validation errors (using formRequests), of course I see invalid labels.. like 'pkg' and not the translated string.

Maybe you can share some ideas on this? :)

Thank you!

[Laravel 5.0.6] Dynamic add fields

I have problem with add field in controller

When I try add fields

$form = \FormBuilder::plain(
            ['method'=>'post','url'=>url(\Config::get('app.locale').'/backend/translates/save-translate')])
->add('foo','text',['label'=>'foo','wrapper'=>['class'=>'large-4']]);        

but

$form = \FormBuilder::plain(
            ['method'=>'post','url'=>url(\Config::get('app.locale').'/backend/translates/save-translate')])
        ;




        if($existTranslates->count()>0){
            foreach($existTranslates->get() as $row){
                $form->add($row->key,'text',['label'=>$row->key,'wrapper'=>['class'=>'large-4']]);
            }
        }

result is empty page.

BTW,
I can add data by plain or addData method. Fileds are empty after rendering.
example

$form = \FormBuilder::plain(
            ['method'=>'post','url'=>url(\Config::get('app.locale').'/backend/translates/save-translate')],['foo'=>'bar'])
->add('foo','text',['label'=>'foo','wrapper'=>['class'=>'large-4']]);        

is empty, same

$form = \FormBuilder::plain(
            ['method'=>'post','url'=>url(\Config::get('app.locale').'/backend/translates/save-translate')])
->add('foo','text',['label'=>'foo','wrapper'=>['class'=>'large-4']])->addData(['foo'=>'bar']);        

Add addtional html for the form input

Is there any posibility to add additional html to form inputs . for instance , I would like to add a span on label to make it a required filed
Name *

Custom form objects

Is there an inteface for adding custom form objects beyond the standard HTML form objects. Have a need to add some custom angular directives in the forms I am creating.

I can easily modify the package code, but curious if there is already an inteface in place for this capability?

Form::select selected not working

Hi,

I'm trying to use this form builder in my project. Everything is fine except this one:

when I navigate to edit page, noo select field is selected!
I investigated in your code and I found something wrong: In views/select.php you cast $options['selected'] as an array:

<?= Form::select($name, (array)$emptyVal + $options['choices'], (array)$options['selected'], $options['attr']) ?>

But in Laravel default formbuilder in getValueAttribute function, it checks:
if ( ! is_null($value)) return $value;

So an empty array never is null and select field never show selected value in the edit screen. By changing your above code to this one: (removing array casting for selected)

<?= Form::select($name, (array)$emptyVal + $options['choices'], $options['selected'], $options['attr']) ?>

everything goes fine!

Is this a bug?

Choice broken?

Getting an error form choice.php line 12

Error: Call to a member function render() on string

It seems to be calling ->render() on the choice value rather than the form element itself. Could you take a look at this? Dont know the choice structure well enough to know whether this is intended and if its an error up the line or not.

'label' option not working on child forms?

Adding a child form the 'label' option doesnt seem to work.

Main form


        $this
            ->add('first_name', 'text', [
                'label' => 'First Name'
                ])
            ->add('last_name', 'text', [
                'label' => 'Last Name'
                ])
            ->add('email', 'email', [
                'label' => 'Email'
                ])
            ->add('address', 'form', [
                'label' => 'Address',
                'class' => \FormBuilder::create('Ntech\Http\Forms\Support\Address')
                ])
            ->add('Create Customer', 'submit');

Child form

        $this
            ->add('street1', 'text', [
                'label' => 'Street 1',
                'attr' => [
                    'placeholder' => 'Street'
                    ]
                ])
            ->add('street2', 'text', [
                'label' => 'Street 2',
                'attr' => [
                    'placeholder' => 'Street'
                    ]
                ])
            ->add('city', 'text', [
                'label' => 'City',
                'attr' => [
                    'placeholder' => 'City'
                    ]
                ])
            ->add('postcode', 'text', [
                'label' => 'Postcode',
                'attr' => [
                    'placeholder' => 'Postcode'
                    ]
                ]);

How to access related one information

Created a form as follows, doesnt want to pull in the Company information, suggestions?

add('active', 'checkbox', ['label' => 'Active'])
            ->add('salutation', 'text', ['label' => 'Salutation:'])
            ->add('company.name', 'text', ['label' => 'Company:'])
            ->add('company.country', 'text', ['label' => 'Country:'])
            ->add('first_name', 'text', ['label' => 'First Name:'])
            ->add('last_name', 'text', ['label' => 'Last Name:'])
            ->add('email', 'text', ['label' => 'EMail:'])
            ->add('phone', 'text', ['label' => 'Phone:'])
            ->add('Save', 'submit', [
                'attr' => ['class' => 'btn btn-primary']
            ]);
    }
}

DateTime Custom Field

Hello Kristi,

Thank you for this project.

Please could you send me a sample for a datetime custom field, I really need it for my project.

Thanks

Adding custom fields from inside another package (Laravel 4)

I'm having trouble adding custom fields from inside a separate package.

The problem:

Since I'm using this package from another package, I can't seem to modify / override the custom fields array from your package config file. I've also added your service provider before mine so there shouldn't be an issue of your service provider overriding the config values I've just set.

I've tried modifying the config at runtime through my packages service provider in the register() function like so:

$this->app->config->set('laravel-form-builder::custom-fields', array(
     'select-category' => 'Stevebauman\Maintenance\Forms\Fields\WorkOrderCategoryField',
));

I can add these custom fields fine when building the form like you've shown in the documentation (which is also amazing), but I need these custom fields available for all of my forms unfortunately.

Would you happen to know anything I can try?

Thanks for the great package!

EDIT:

I have tried this in my register() function as well:

$this->app['laravel-form-helper']->addCustomField('select-category', 'Stevebauman\Maintenance\Forms\Fields\Select\WorkOrderCategoryField');

But this gives a View [] not found exception in my blade view where I call the {{ form($form) }} function

[Laravel 4] One-to-many nested form collections

Hi!
Is this possible to create nested form collections for one-to-many relationships?
Its something like 'form' form type here, but not for a single form, but with a collection of forms.
And is there any prototyping solution, just like in Symfony2's collection form type?
Thank you very much!

Default value in text inputs

Hi,

im trying to set a default value into a text input. But it won't work and i can't get the reason why...

Part of the form class:

public function buildForm() {
    $this->add('myfield', 'text', ['label' => 'My field']);

Part of the controller class:

$form = $formBuilder->create(
    'Forms\MyForm',
    ['method' => 'POST'],
    ['myfield' => 'Default text for my field']);

The form will be rendered but with empty fields. The only way to put some data into it was to use "default_value" inside the form class. But this can't be the way...

Many thanks for any kind of hints!

Buttons collection

How can I make buttons collection where values from model will be buttons labels?

When I set buttons collection as result I see buttons and for every button label is field name.

multipart data and collection

I tried in child form, and normal form. Works same.

When you add field type file, form has

 enctype="multipart/form-data"

attribute. But if you add file type in collection it not works.

[Laravel 5] [Request] Method Injection

How do you feel about setting it up so that we can inject the form directly into the controller method and bypass the FormBuilder::create() call? It looks like the main thing that would need to be changed is passing the FormHelper into the Form constructor rather than setting it after initialization, unless I'm overlooking something.

I could try to make the changes and do a pull request, but I'm quite new to this whole thing and really don't have a clue about what I'm doing when it comes to contributing.

[Laravel 5][version 1.3] Wrapper not work when label is false

When you add

\FormBuilder::plain()->add('foo','text',['wrapper'=>['class'=>'bar']]);

all works fine,
but after change to:

\FormBuilder::plain()->add('foo','text',['wrapper'=>['class'=>'bar'],'label'=>false]);

wrapper is not render.

Of course, it's possible to fix by set nbsp for label. But then label still exist.

Default Namespace / Prepend Form Class

Similar to what the RouteServiceProvider does it would be nice to have a config option to provide a default namespace that gets prepended to the $formClass in FormBuilder::create.

In the config file you might have:
'default_namespace' => 'App\Http\Forms'

Then when initiating forms in controller methods you could have:
$form = FormBuilder::create('PasswordResetRequest');

Instead of:
$form = FormBuilder::create('App\Http\Forms\PasswordResetRequest');

Support setting arbitrary properties

Hi! First, this package seems like a great idea, so thanks for that! I haven't had time to play with it yet, but I will as soon as I get the chance.

So far, I've mostly just read the docs and browsed the source code to try and figure out how I'm gonna be using this in the future (and I do plan on doing that), and I'm not sure I'm able to do something - for example, I have a <select> element that I want to populate with external data (e.g. something from the database that is not model-related, or something from language files, etc.) - e.g. the provided examples have 'choices' hard-coded into the custom form classes, but I want to inject that data from elsewhere.

A possible workaround (a bit primitive) would be to add custom setters to extended classes, so my form class would look something like this (boilerplate code omitted for brevity):

class FooForm extends Form
{
    protected $genderChoices = [];

    public function buildForm()
    {
        $this
            ->add('gender', 'choice', [
                'choices' => $this->genderChoices,
                'selected' => 'm',
                'expanded' => true
            ]);
    }

    public function setGenderChoices(array $genderChoices = [])
    {
        $this->genderChoices = $genderChoices;

        return $this;
    }
}

Is this the intended way of working with external data?

Alternatively, the Form class in this package could define a _call() magic method to intercept undeclared setter methods, extract the property name from the name of the invoked method, and automatically save it to some internal property - e.g. $form->setFooBar($baz) would internally call $this->data['fooBar'] = $bar, so we could use $this->data['fooBar'] in places where we need it (or something like $this->getData('fooBar') to avoid manual isset() checks)? It might not be the cleanest solution, but I'm not sure how I'm supposed to do this - it's getting late here, so I'm not even sure if I'm making much sense.

Either way, thanks in advance for your thoughts on this.

Cheers!

Injecting model to sub-forms?

Is this possible at the moment?
Or is it sensible acheivable beyond setting a model variable on the form which is passed to the sub-form?

Hidden Field

I was trying to create a hidden field in a form:

public function buildForm()
{
$this
->setUrl('admin/provacionistas')
->add('nome', 'text', 'Nome:)
->add('escola_id','hidden',['value' => '1'])

But it did not work:

        <input class="form-control" id="escola_id" name="escola_id" type="hidden">

Somehow, the value tag is not there.
Is there another way to set a hidden variable in a form?

Namespaces

When creating a form, I used the code as in the example which caused the namespace to become Myapp\NamespaceForms\PostForm I needed to manually add the missing backslash to make it Myapp\Namespace\Forms\PostForm

form_close helper and display/hide some parts of form

@kristijanhusak
I have MainForm and 4 form inside. I set it to view by form_row but...
one form is depends from some variable state. This form should be display or not.
Unfortunately when I use form_close all not display earlier forms are printed.

I need print

// pseudo code
form_row(form1);
from_row(form2);
if(foo==bar)
form_row(form3) ;

and of course have end form mark.

In controller I can remove form based on this variable. But it's impossible not print only?

Field Box

Hi, is there a way to create a method for adding a box who contains fields?

I want forms with some fields on same line like password and password_confirmation

I hope you understand what i mean. My english is not the best ;)

Kind Regards

Custom fields via config don't work

Hey,

Tried creating a new custom field type. It's only working via $this->addCustomField() in the Form object, when I add it to custom fields I just get "Unsupported field type exception":

    'custom_fields' => [
        'dob' => 'App\Http\Forms\Fields\DobType'
    ],

Any ideas?

P.S. Is the "Type" suffix on custom field classes mandatory or just a naming convention you've used?

[Laravel 5] wrapper for each field in collection

If is possible use "choice, expanded=>true, multiple=>true"
We can add wrapper for all fields. How can we make wrapper for each label with checkbox field?

for example we would like add div or span as wrapper

<div class="general_wrapper_from_config">
<div class="wrapper">
<label for="x"><input type="checkbox"> Label text </label>
</div>

<div class="wrapper">
<label for="xy"><input type="checkbox"> Label text </label>
</div>
</div>

[Laravel 5 ][version1.3.1] Can't populate fields from other different class/array

@kristijanhusak
I have class with fields:

When I'd like fill fields from eloquent model, it's no problem. User model and all works.

But, when I want bind values to fields in controller from other source, it big problem.

Not work:
use stdClass as model property
use array as model property
use array [field_name=>value] in third create function argument.

examples:
newTranslate form

public function buildForm()
    {
        $this
            ->add('section', 'hidden')
            ->add('submit', 'submit',['attr'=>['class'=>'tiny secondary'],'label'=>trans('translate.add_new_translate')]);
    }

controller code

$model = new stdClass();
$model->section = 'bar';
$newForm = \FormBuilder::create('App\Forms\Backend\NewTranslate',[
            'method'=>'post',
            'url'=>url(\Config::get('app.locale').'/backend/translates/create'),
'model'=>$model // not work

        ]);

$model = ['section'=>'bar'];

$newForm = \FormBuilder::create('App\Forms\Backend\NewTranslate',[
            'method'=>'post',
            'url'=>url(\Config::get('app.locale').'/backend/translates/create'),
'model'=>$model // not work

        ]);

and


$model = ['section'=>'bar'];

$newForm = \FormBuilder::create('App\Forms\Backend\NewTranslate',[
            'method'=>'post',
            'url'=>url(\Config::get('app.locale').'/backend/translates/create'),


        ],$model); // also not work

In every case value is empty.

How can I resolve this problem. Because, add to every form function to fill default value it make no sense.

Perfect solution will be, possible use array/stdClass as model or accept array from third argument in FormBuilder::create function


EDIT:
Of course I can use on FormBuilder class:
->getField('section')->setOptions(['default_value'=>'bar');

but for many fields it's not comfortable.

Child forms clickable labels for checkbox

When you use child form to label for attribute is added name field. To checkbox also is addes id like name. So for child forms checkbox name is for example


<input type="checkbox" name="dataForm[approved] id="approved" />
<label for="dataform[approved]">Approved</label>

In id not exists array. In result after click on label checkbox is not selected.

It is possible to solve without javascript? (I know that in html, I mean form-builder)

Needed cancel type too

Avaiable types are: text, email, url, tel, search, password, hidden, number, date, textarea, submit, reset, button, file, image, select, checkbox, radio, choice, form, repeated.
Needed cancel type too. To cancel the form and to redirect

Multiple error messages on 'choice' type

For example I use this:

            ->add('active', 'choice', [
                'choices' => [1 => __('btn_yes'), 0 => __('btn_no')],
                'selected' => true,
                'expanded' => true,
            ])

And get these:
The active field must be true or false.
The active field must be true or false.
The active field must be true or false.

Am I missing something?

choices type field not populating value

In $this->add('fields', 'choice', [
'choices' => ['choice1' => 'choice1', 'choice2' => 'choice2'],
'empty_value' => 'Select',
'multiple' => TRUE,
'attr' => ['class' => 'multiple-input'],
])
value is not populating through model,passing value as $model->fields = ['choice1']
$form = \FormBuilder::create('Form', [
'method' => 'PUT',
'url' => route('update', $id),
'model' => $model
]);

form_rest and model

@kristijanhusak
When I use form_rest helper fields are not filled data from model. I can't see any option in config to change it.

I need render form without start and close tags because I use more forms class in one view and one request. But to nice formatting impossible is use one class.

How to add div row between fields and buttons

Assuming I have a setup like below, curious how to create a new 'row' between last field and buttons

...
            ->add('email', 'text', ['label' => 'EMail:'])

            ->add('Save', 'submit', ['attr' => ['class' => 'btn btn-primary']])
            ->add('Cancel', 'submit', ['attr' => ['class' => 'btn']]);
...

datetime-local from model

When using the datetime-local type and importing values from a model, it sets the field value to something like 2015-04-23 19:29:00 instead of the required 2015-04-23T19:29:00, probably a simple fix. If I can find where it populates values off models, I'll attempt to fix it and create a pull request.

This seems to be an issue that might be out of your control, though.

Build form from serveral parts

Hello,

is there a way, so I can, for example:

public function buildForm()
    {
        $this
            ->add('name_tab1', 'text')
            ->add('slug_tab1', 'text', [
                'attr' => ['autocomplete' => 'off'],
            ])
            ->add('active', 'choice', [
                'choices' => [1 => __('btn_yes'), 0 => __('btn_no')],
                'selected' => true,
                'expanded' => true,
            ]);
    }

public function buildForm()
    {
        $this
            ->add('name_tab2', 'text')
            ->add('slug_tab2', 'text', [
                'attr' => ['autocomplete' => 'off'],
            ])
            ->add('active', 'choice', [
                'choices' => [1 => __('btn_yes'), 0 => __('btn_no')],
                'selected' => true,
                'expanded' => true,
            ]);
    }

public function buildForm()
    {
        $this
            ->add('bottom_div_clear', 'reset', [
                'attr' => ['class' => 'btn btn-xs btn-default']
            ])
            ->add('bottom_div_submit', 'submit', [
                'label' => $this->getSubmitBtn(),
                'attr' => ['class' => 'btn btn-primary']
            ]);
    }

What I want to achieve, display 1st part - on TAB1, 2nd part on TAB3 and part3 inside special div..

Is this possible with this lib?

Thank you!

validation

Hello,

are you planing to bind validation too? Since we already have field types, names etc.
other question would be are you planing to make it work outside laravel?

Thanks

Make command error and differs from Laravel 5 layout

Hey,
Awesome package, was just checking out the make command

php artisan laravel-form-builder:make Forms/PostForm

Firstly, when this is ran I get a feedback message

 created successfully.

Presume its meant to state the filepath that was created.

Secondly, with the new layout of Laravel, do you think it would be better to have the forms generate into app/Http/Forms instead of app/Forms as these are Http layer specific? Perhaps could make this a config value.

I would submit a PR but havnt used the Generator command and cant quite figure out how the command works at first looks.

Cheers.

Default namespace not read from config file

I tried setting default_namespace from config/laravel-form-builder.php, but it is getting ignored for some reason. Instead, I set it in my ConfigServiceProvider and that is working fine.
Edit: nevermind, didn't see I had added it in the config file twice.

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.