Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
],
"require": {
"php": ">=7.1.3",
"illuminate/support": "5.8.*",
"illuminate/filesystem": "5.8.*",
"kris/laravel-form-builder": "1.6.12",
"illuminate/support": "5.8.*|^6.0",
"illuminate/filesystem": "5.8.*|^6.0",
"kris/laravel-form-builder": "1.*",
"cloudinary/cloudinary_php": "dev-master"
},
"require-dev": {
"orchestra/database": "3.8.*",
"orchestra/testbench": "3.8.*",
"orchestra/testbench-browser-kit": "3.8.*",
"phpunit/phpunit": "~7.0",
"mockery/mockery": "~1.0",
"orchestra/database": "3.8.*|^4.0",
"orchestra/testbench": "3.8.*|^4.0",
"orchestra/testbench-browser-kit": "3.8.*|^4.0",
"phpunit/phpunit": "~7.0|^8.3",
"mockery/mockery": "~1.0|^1.2.3",
"fzaninotto/faker": "~1.4"
},
"autoload": {
Expand Down
3 changes: 2 additions & 1 deletion src/Distilleries/FormBuilder/Fields/ChildFormType.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Distilleries\FormBuilder\Fields;

use Illuminate\Support\Arr;
use Kris\LaravelFormBuilder\Form;

class ChildFormType extends ParentType {
Expand Down Expand Up @@ -36,7 +37,7 @@ protected function createChildren()
*/
public function getClass()
{
$class = array_get($this->options, 'class');
$class = Arr::get($this->options, 'class');

if ($class && $class instanceof Form)
{
Expand Down
8 changes: 6 additions & 2 deletions src/Distilleries/FormBuilder/Fields/ChoiceType.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php namespace Distilleries\FormBuilder\Fields;
<?php

namespace Distilleries\FormBuilder\Fields;

use Illuminate\Support\Str;

class ChoiceType extends ParentType
{
Expand Down Expand Up @@ -75,7 +79,7 @@ protected function createChildren()
protected function buildCheckableChildren($fieldType, $fieldMultiple)
{
foreach ((array) $this->options['choices'] as $key => $choice) {
$id = str_slug($choice).'_'.$key;
$id = Str::slug($choice).'_'.$key;
$this->children[] = new $fieldType(
$this->name.$fieldMultiple,
$this->choiceType,
Expand Down
8 changes: 5 additions & 3 deletions src/Distilleries/FormBuilder/Fields/ParentType.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php namespace Distilleries\FormBuilder\Fields;
<?php

namespace Distilleries\FormBuilder\Fields;

use Illuminate\Support\Arr;
use Kris\LaravelFormBuilder\Form;

abstract class ParentType extends FormFieldsView
{

/**
* @var mixed
*/
Expand Down Expand Up @@ -49,7 +51,7 @@ public function getChildren()
*/
public function getChild($key)
{
return array_get($this->children, $key);
return Arr::get($this->children, $key);
}

public function isRendered()
Expand Down
25 changes: 22 additions & 3 deletions src/Distilleries/FormBuilder/FormBuilderServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
use Collective\Html\FormBuilder as LaravelForm;
use Collective\Html\HtmlBuilder as LaravelHtml;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Foundation\Application;
use Kris\LaravelFormBuilder\Form;
use Kris\LaravelFormBuilder\FormBuilder;
use Kris\LaravelFormBuilder\FormBuilderServiceProvider as BaseFormBuilderServiceProvider;
use Kris\LaravelFormBuilder\FormHelper;
use Kris\LaravelFormBuilder\Traits\ValidatesWhenResolved;

class FormBuilderServiceProvider extends BaseFormBuilderServiceProvider
{
Expand Down Expand Up @@ -37,19 +40,35 @@ public function register()
$this->registerFormHelper();

$this->app->singleton('laravel-form-builder', function ($app) {
return new FormBuilder($app, $app['laravel-form-helper']);
return new FormBuilder($app, $app['laravel-form-helper'], $app['events']);
});

$this->commands(\Distilleries\FormBuilder\Console\FormMakeCommand::class);

$this->alias();

$this->app->afterResolving(Form::class, function ($object, Application $app) {
/** @var \Illuminate\Http\Request $request */
$request = $app->make('request');

if (in_array(ValidatesWhenResolved::class, class_uses($object)) && $request->method() !== 'GET') {
$form = $app->make('laravel-form-builder')->setDependenciesAndOptions($object);
$form->buildForm();
//$form->redirectIfNotValid();
}
});
}

/**
* {@inheritDoc}
*/
protected function registerFormHelper()
{
$this->app->singleton('laravel-form-helper', function ($app) {
$config = $app['config']->get('form-builder');
return new FormHelper($app['view'], $app['request'], $config);

$configuration = $app['config']->get('form-builder');

return new FormHelper($app['view'], $app['translator'], $configuration);
});

$this->app->alias('laravel-form-helper', 'Kris\LaravelFormBuilder\FormHelper');
Expand Down
Loading