From 0e14cd3843a0ccca891792dabd967733e4831d17 Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 20 Jan 2021 21:28:00 +0100 Subject: [PATCH] wip #4216 @1 --- src/app/Console/Commands/CubistMagicCommand.php | 2 +- src/app/Magic/Fields/Field.php | 10 ++++++++-- src/app/Magic/Fields/FormSection.php | 13 +++++++++++++ src/resources/views/fields/form_section.blade.php | 7 +++++++ src/resources/views/fields/form_separator.blade.php | 3 +++ 5 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 src/app/Magic/Fields/FormSection.php create mode 100644 src/resources/views/fields/form_section.blade.php create mode 100644 src/resources/views/fields/form_separator.blade.php diff --git a/src/app/Console/Commands/CubistMagicCommand.php b/src/app/Console/Commands/CubistMagicCommand.php index a76d696..73b5425 100644 --- a/src/app/Console/Commands/CubistMagicCommand.php +++ b/src/app/Console/Commands/CubistMagicCommand.php @@ -29,7 +29,7 @@ class CubistMagicCommand extends CubistCommand } } } catch (\Exception $e) { - $this->line($e->getTraceAsString()); + $this->line($e->getMessage()."\n".$e->getTraceAsString()); } } } diff --git a/src/app/Magic/Fields/Field.php b/src/app/Magic/Fields/Field.php index 5c68568..34e2af5 100644 --- a/src/app/Magic/Fields/Field.php +++ b/src/app/Magic/Fields/Field.php @@ -73,8 +73,13 @@ class Field implements \ArrayAccess $class = static::_getClass($attributes['type']); unset($attributes['type']); - if (!is_subclass_of($class, UnstoredField::class) && !isset($attributes['name'])) { - throw new Exception('You must specify a field name'); + if (!isset($attributes['name'])) { + if (!is_subclass_of($class, UnstoredField::class)) { + throw new Exception('You must specify a field name'); + } else { + $attributes['name'] = 'gen_' . sha1(rand(1, 1000000000000)); + } + } return new $class($attributes); } @@ -138,6 +143,7 @@ class Field implements \ArrayAccess public function __construct($attributes) { $this->_attributes = $this->getDefaultAttributes(); + foreach ($attributes as $attribute => $value) { $this->setAttribute($attribute, $value); } diff --git a/src/app/Magic/Fields/FormSection.php b/src/app/Magic/Fields/FormSection.php new file mode 100644 index 0000000..17ad8ed --- /dev/null +++ b/src/app/Magic/Fields/FormSection.php @@ -0,0 +1,13 @@ + + +
+
+@include('crud::fields.inc.wrapper_start') +

{{$field['label']}}

+@include('crud::fields.inc.wrapper_end') diff --git a/src/resources/views/fields/form_separator.blade.php b/src/resources/views/fields/form_separator.blade.php new file mode 100644 index 0000000..c723c26 --- /dev/null +++ b/src/resources/views/fields/form_separator.blade.php @@ -0,0 +1,3 @@ +@include('crud::fields.inc.wrapper_start') +
+@include('crud::fields.inc.wrapper_end') -- 2.39.5