From 4d94ae28784c56c6f58a1713af44f3f0442b10a0 Mon Sep 17 00:00:00 2001 From: Nafies Luthfi Date: Wed, 29 Aug 2018 17:42:53 +0800 Subject: [PATCH] Remove FormField from simple crud edit form --- src/stubs/resources/views/simple/forms.stub | 42 ++++++++++++++------------ tests/Generators/Simple/ViewsGeneratorTest.php | 42 ++++++++++++++------------ 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/src/stubs/resources/views/simple/forms.stub b/src/stubs/resources/views/simple/forms.stub index dc1399b..d1e830b 100644 --- a/src/stubs/resources/views/simple/forms.stub +++ b/src/stubs/resources/views/simple/forms.stub @@ -19,26 +19,28 @@ @endif @if (Request::get('action') == 'edit' && $editableMaster) @can('update', $editableMaster) - {{ Form::model($editableMaster, ['route' => ['masters.update', $editableMaster], 'method' => 'patch']) }} - {!! FormField::text('name', ['required' => true, 'label' => __('master.name')]) !!} - {!! FormField::textarea('description', ['label' => __('master.description')]) !!} - @if (request('q')) - {{ Form::hidden('q', request('q')) }} - @endif - @if (request('page')) - {{ Form::hidden('page', request('page')) }} - @endif - {{ Form::submit(__('master.update'), ['class' => 'btn btn-success']) }} - {{ link_to_route('masters.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }} - @can('delete', $editableMaster) - {{ link_to_route( - 'masters.index', - __('app.delete'), - ['action' => 'delete', 'id' => $editableMaster->id] + Request::only('page', 'q'), - ['id' => 'del-master-'.$editableMaster->id, 'class' => 'btn btn-danger pull-right'] - ) }} - @endcan - {{ Form::close() }} +
+ {{ csrf_field() }} {{ method_field('patch') }} +
+
+ + + {!! $errors->first('name', ':message') !!} +
+
+ + + {!! $errors->first('description', ':message') !!} +
+
+ +
@endcan @endif @if (Request::get('action') == 'delete' && $editableMaster) diff --git a/tests/Generators/Simple/ViewsGeneratorTest.php b/tests/Generators/Simple/ViewsGeneratorTest.php index 089be3f..cbb7343 100644 --- a/tests/Generators/Simple/ViewsGeneratorTest.php +++ b/tests/Generators/Simple/ViewsGeneratorTest.php @@ -107,26 +107,28 @@ class ViewsGeneratorTest extends TestCase @endif @if (Request::get('action') == 'edit' && \$editable{$this->model_name}) @can('update', \$editable{$this->model_name}) - {{ Form::model(\$editable{$this->model_name}, ['route' => ['{$this->table_name}.update', \$editable{$this->model_name}], 'method' => 'patch']) }} - {!! FormField::text('name', ['required' => true, 'label' => __('{$this->lang_name}.name')]) !!} - {!! FormField::textarea('description', ['label' => __('{$this->lang_name}.description')]) !!} - @if (request('q')) - {{ Form::hidden('q', request('q')) }} - @endif - @if (request('page')) - {{ Form::hidden('page', request('page')) }} - @endif - {{ Form::submit(__('{$this->lang_name}.update'), ['class' => 'btn btn-success']) }} - {{ link_to_route('{$this->table_name}.index', __('app.cancel'), Request::only('page', 'q'), ['class' => 'btn btn-default']) }} - @can('delete', \$editable{$this->model_name}) - {{ link_to_route( - '{$this->table_name}.index', - __('app.delete'), - ['action' => 'delete', 'id' => \$editable{$this->model_name}->id] + Request::only('page', 'q'), - ['id' => 'del-{$this->lang_name}-'.\$editable{$this->model_name}->id, 'class' => 'btn btn-danger pull-right'] - ) }} - @endcan - {{ Form::close() }} +
table_name}.update', \$editable{$this->model_name}) }}\" accept-charset=\"UTF-8\"> + {{ csrf_field() }} {{ method_field('patch') }} +
+
has('name') ? ' has-error' : '' }}\"> + + model_name}->name) }}\" required> + {!! \$errors->first('name', ':message') !!} +
+
has('description') ? ' has-error' : '' }}\"> + + + {!! \$errors->first('description', ':message') !!} +
+
+ +
@endcan @endif @if (Request::get('action') == 'delete' && \$editable{$this->model_name})