From dc1d4ddf161e2801346eb476618066def0433a7f Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 07:09:57 +0800 Subject: [PATCH] Remove FormField on full CRUD create form Move FormFieldversion of create form to new stub file --- .../resources/views/full/create-formfield.stub | 23 +++++++++++++++++ src/stubs/resources/views/full/create.stub | 29 ++++++++++++++-------- tests/Generators/ViewsGeneratorTest.php | 29 ++++++++++++++-------- 3 files changed, 61 insertions(+), 20 deletions(-) create mode 100644 src/stubs/resources/views/full/create-formfield.stub diff --git a/src/stubs/resources/views/full/create-formfield.stub b/src/stubs/resources/views/full/create-formfield.stub new file mode 100644 index 0000000..b4f2704 --- /dev/null +++ b/src/stubs/resources/views/full/create-formfield.stub @@ -0,0 +1,23 @@ +@extends('layouts.app') + +@section('title', __('master.create')) + +@section('content') +
+
+
+

{{ __('master.create') }}

+ {!! Form::open(['route' => 'masters.store']) !!} +
+ {!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!} + {!! FormField::textarea('description', ['label' => __('master.description')]) !!} +
+ + {!! Form::close() !!} +
+
+
+@endsection diff --git a/src/stubs/resources/views/full/create.stub b/src/stubs/resources/views/full/create.stub index b4f2704..27e585d 100644 --- a/src/stubs/resources/views/full/create.stub +++ b/src/stubs/resources/views/full/create.stub @@ -7,16 +7,25 @@

{{ __('master.create') }}

- {!! Form::open(['route' => 'masters.store']) !!} -
- {!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!} - {!! FormField::textarea('description', ['label' => __('master.description')]) !!} -
- - {!! Form::close() !!} +
+ {{ csrf_field() }} +
+
+ + + {!! $errors->first('name', ':message') !!} +
+
+ + + {!! $errors->first('description', ':message') !!} +
+
+ +
diff --git a/tests/Generators/ViewsGeneratorTest.php b/tests/Generators/ViewsGeneratorTest.php index 926119b..91c6ec2 100644 --- a/tests/Generators/ViewsGeneratorTest.php +++ b/tests/Generators/ViewsGeneratorTest.php @@ -128,16 +128,25 @@ class ViewsGeneratorTest extends TestCase

{{ __('{$this->lang_name}.create') }}

- {!! Form::open(['route' => '{$this->table_name}.store']) !!} -
- {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} - {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!} -
-
- {!! Form::submit(__('{$this->lang_name}.create'), ['class' => 'btn btn-success']) !!} - {{ link_to_route('{$this->table_name}.index', __('app.cancel'), [], ['class' => 'btn btn-default']) }} -
- {!! Form::close() !!} +
table_name}.store') }}\" accept-charset=\"UTF-8\"> + {{ csrf_field() }} +
+
has('name') ? ' has-error' : '' }}\"> + + + {!! \$errors->first('name', ':message') !!} +
+
has('description') ? ' has-error' : '' }}\"> + + + {!! \$errors->first('description', ':message') !!} +
+
+
+ lang_name}.create') }}\" class=\"btn btn-success\"> + table_name}.index') }}\" class=\"btn btn-default\">{{ __('app.cancel') }} +
+