From 1157446544459a8aed2bbc4c22d37f704d6ee43f Mon Sep 17 00:00:00 2001 From: Andy Heathershaw Date: Fri, 28 Oct 2016 14:05:53 +0100 Subject: [PATCH] BLUE-4: All form validation is now displayed inline with the form. --- .../Controllers/Admin/DefaultController.php | 2 +- .../Controllers/Admin/PhotoController.php | 3 +- resources/lang/en/validation.php | 3 +- .../themes/base/admin/create_album.blade.php | 18 ++++---- .../themes/base/admin/create_user.blade.php | 42 ++++++++++++------- .../themes/base/admin/edit_album.blade.php | 18 ++++---- .../themes/base/admin/edit_user.blade.php | 42 ++++++++++++------- .../themes/base/admin/show_album.blade.php | 8 +++- .../partials/single_photo_admin.blade.php | 9 +++- 9 files changed, 90 insertions(+), 55 deletions(-) diff --git a/app/Http/Controllers/Admin/DefaultController.php b/app/Http/Controllers/Admin/DefaultController.php index 0f0fc6c..ae0cd02 100644 --- a/app/Http/Controllers/Admin/DefaultController.php +++ b/app/Http/Controllers/Admin/DefaultController.php @@ -96,7 +96,7 @@ class DefaultController extends Controller } $config->value = $request->request->get($key); - if (in_array($key, $passwordKeys)) + if (in_array($key, $passwordKeys) && strlen($config->value) > 0) { $config->value = encrypt($config->value); } diff --git a/app/Http/Controllers/Admin/PhotoController.php b/app/Http/Controllers/Admin/PhotoController.php index aba26c6..a2cf3b4 100644 --- a/app/Http/Controllers/Admin/PhotoController.php +++ b/app/Http/Controllers/Admin/PhotoController.php @@ -9,6 +9,7 @@ use App\Facade\Theme; use App\Helpers\FileHelper; use App\Helpers\ImageHelper; use App\Helpers\MiscHelper; +use App\Http\Requests\UpdatePhotosBulkRequest; use App\Photo; use App\Services\PhotoService; use App\Upload; @@ -395,7 +396,7 @@ class PhotoController extends Controller // } - public function updateBulk(Request $request, $albumId) + public function updateBulk(UpdatePhotosBulkRequest $request, $albumId) { $this->authorize('admin-access'); diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index dd4cb1e..55ccb52 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -115,5 +115,6 @@ return [ // Added by Andy H. for custom validators 'dir_empty' => 'The path must be an empty folder.', 'is_dir' => 'The folder must be a valid directory.', - 'is_writeable' => 'Unable to write to this folder - please check permissions.' + 'is_writeable' => 'Unable to write to this folder - please check permissions.', + 'photo_name_required' => 'The name field is required.' ]; diff --git a/resources/views/themes/base/admin/create_album.blade.php b/resources/views/themes/base/admin/create_album.blade.php index 24806e1..dd9aed6 100644 --- a/resources/views/themes/base/admin/create_album.blade.php +++ b/resources/views/themes/base/admin/create_album.blade.php @@ -23,20 +23,16 @@

@lang('admin.create_album_intro2')


- @if (count($errors) > 0) -
- -
- @endif - {!! Form::open(['route' => 'albums.store', 'method' => 'POST']) !!} -
+
{!! Form::label('name', trans('forms.name_label'), ['class' => 'control-label']) !!} {!! Form::text('name', old('name'), ['class' => 'form-control']) !!} + + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif
diff --git a/resources/views/themes/base/admin/create_user.blade.php b/resources/views/themes/base/admin/create_user.blade.php index eff3eab..d80bc43 100644 --- a/resources/views/themes/base/admin/create_user.blade.php +++ b/resources/views/themes/base/admin/create_user.blade.php @@ -22,45 +22,59 @@

@lang('admin.create_user_intro')


- @if (count($errors) > 0) -
-
    - @foreach ($errors->all() as $form_error) -
  • {{ $form_error }}
  • - @endforeach -
-
- @endif - {!! Form::open(['route' => 'user.store', 'method' => 'POST']) !!}
-
+
{!! Form::label('name', trans('forms.name_label'), ['class' => 'control-label']) !!} {!! Form::text('name', old('name'), ['class' => 'form-control']) !!} + + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif
-
+
{!! Form::label('email', trans('forms.email_label'), ['class' => 'control-label']) !!} {!! Form::text('email', old('email'), ['class' => 'form-control']) !!} + + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif
-
+
{!! Form::label('password', trans('forms.password_label'), ['class' => 'control-label']) !!} {!! Form::password('password', ['class' => 'form-control']) !!} + + @if ($errors->has('password')) + + {{ $errors->first('password') }} + + @endif
-
+
{!! Form::label('password_confirmation', trans('forms.password_confirm_label'), ['class' => 'control-label']) !!} {!! Form::password('password_confirmation', ['class' => 'form-control']) !!} + + @if ($errors->has('password_confirmation')) + + {{ $errors->first('password_confirmation') }} + + @endif
diff --git a/resources/views/themes/base/admin/edit_album.blade.php b/resources/views/themes/base/admin/edit_album.blade.php index 2008620..944b91d 100644 --- a/resources/views/themes/base/admin/edit_album.blade.php +++ b/resources/views/themes/base/admin/edit_album.blade.php @@ -24,20 +24,16 @@

@lang('admin.edit_album_intro2', ['album_name' => $album->name])


- @if (count($errors) > 0) -
-
    - @foreach ($errors->all() as $error) -
  • {{ $error }}
  • - @endforeach -
-
- @endif - {!! Form::model($album, ['route' => ['albums.update', $album->id], 'method' => 'PUT']) !!} -
+
{!! Form::label('name', trans('forms.name_label'), ['class' => 'control-label']) !!} {!! Form::text('name', old('name'), ['class' => 'form-control']) !!} + + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif
diff --git a/resources/views/themes/base/admin/edit_user.blade.php b/resources/views/themes/base/admin/edit_user.blade.php index 4adb49f..c2a3aa9 100644 --- a/resources/views/themes/base/admin/edit_user.blade.php +++ b/resources/views/themes/base/admin/edit_user.blade.php @@ -22,45 +22,59 @@

@lang('admin.edit_user_intro')


- @if (count($errors) > 0) -
-
    - @foreach ($errors->all() as $form_error) -
  • {{ $form_error }}
  • - @endforeach -
-
- @endif - {!! Form::model($user, ['route' => ['user.update', $user->id], 'method' => 'PUT']) !!}
-
+
{!! Form::label('name', trans('forms.name_label'), ['class' => 'control-label']) !!} {!! Form::text('name', old('name'), ['class' => 'form-control']) !!} + + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif
-
+
{!! Form::label('email', trans('forms.email_label'), ['class' => 'control-label']) !!} {!! Form::text('email', old('email'), ['class' => 'form-control']) !!} + + @if ($errors->has('email')) + + {{ $errors->first('email') }} + + @endif
-
+
{!! Form::label('password', trans('forms.password_label'), ['class' => 'control-label']) !!} {!! Form::password('password', ['class' => 'form-control']) !!} + + @if ($errors->has('password')) + + {{ $errors->first('password') }} + + @endif
-
+
{!! Form::label('password_confirmation', trans('forms.password_confirm_label'), ['class' => 'control-label']) !!} {!! Form::password('password_confirmation', ['class' => 'form-control']) !!} + + @if ($errors->has('password_confirmation')) + + {{ $errors->first('password_confirmation') }} + + @endif
diff --git a/resources/views/themes/base/admin/show_album.blade.php b/resources/views/themes/base/admin/show_album.blade.php index 759a89f..f407d00 100644 --- a/resources/views/themes/base/admin/show_album.blade.php +++ b/resources/views/themes/base/admin/show_album.blade.php @@ -161,9 +161,15 @@

@lang('admin.album_basic_info_heading')

@lang('admin.album_basic_info_intro')

-
+
{!! Form::label('name', trans('forms.name_label'), ['class' => 'control-label']) !!} {!! Form::text('name', old('name'), ['class' => 'form-control']) !!} + + @if ($errors->has('name')) + + {{ $errors->first('name') }} + + @endif
diff --git a/resources/views/themes/base/partials/single_photo_admin.blade.php b/resources/views/themes/base/partials/single_photo_admin.blade.php index a71af83..bf97bd1 100644 --- a/resources/views/themes/base/partials/single_photo_admin.blade.php +++ b/resources/views/themes/base/partials/single_photo_admin.blade.php @@ -41,9 +41,16 @@

-
+ @php($validation_field_name = ('photo.' . $photo->id . '.name')) +
{!! Form::label($field_prefix . '[name]', trans('forms.name_label'), ['class' => 'control-label']) !!} {!! Form::text($field_prefix . '[name]', old('name', $photo->name), ['class' => 'form-control']) !!} + + @if ($errors->has($validation_field_name)) + + {{ $errors->first($validation_field_name) }} + + @endif