From 256c0b179a6ab92f7c08a984035a6902dadb398c Mon Sep 17 00:00:00 2001 From: Kevin MacMartin Date: Sun, 17 Jun 2018 23:31:24 -0400 Subject: [PATCH] Add in functionality to set a different column type on creation than when being edited --- readme.md | 1 + .../views/dashboard/pages/edit-item.blade.php | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/readme.md b/readme.md index 3f69c96..9bc47b0 100644 --- a/readme.md +++ b/readme.md @@ -208,6 +208,7 @@ Models with their `$dashboard_type` set to `edit` also use: * `file`: Fields that contains file uploads * `display`: Displayed information that can't be edited * `user`: This should point to a foreign key that references the id on the users table; setting this will bind items to the user that created them +* `type-new`: This takes the same options as `type` and overrides it when creating new items (eg: to allow input on a field during creation but not after) * `name`: (required by `file` and `image`) Used along with the record id to determine the filename * `delete`: (optional for `file` and `image`) Enables a delete button for the upload when set to true * `ext`: (required by `file`) Configures the file extension of the upload diff --git a/resources/views/dashboard/pages/edit-item.blade.php b/resources/views/dashboard/pages/edit-item.blade.php index ecd0b29..d19bbae 100644 --- a/resources/views/dashboard/pages/edit-item.blade.php +++ b/resources/views/dashboard/pages/edit-item.blade.php @@ -20,26 +20,27 @@ @foreach($columns as $column)
@set('value', $item[$column['name']]) + @set('type', $id == 'new' && array_key_exists('type-new', $column) ? $column['type-new'] : $column['type']) - @if($column['type'] == 'hidden') + @if($type == 'hidden') - @elseif($column['type'] == 'user') + @elseif($type == 'user') - @elseif($column['type'] != 'display' || $id != 'new') + @elseif($type != 'display' || $id != 'new')
- @if($column['type'] == 'text') + @if($type == 'text') - @elseif($column['type'] == 'date') + @elseif($type == 'date') - @elseif($column['type'] == 'mkd') + @elseif($type == 'mkd')
- @elseif($column['type'] == 'select') + @elseif($type == 'select') - @elseif($column['type'] == 'image') + @elseif($type == 'image') @set('current_image', "/uploads/$model/img/$id-" . $column['name'] . '.jpg') @@ -64,7 +65,7 @@ @endif
@endif - @elseif($column['type'] == 'file') + @elseif($type == 'file') @set('current_file', "/uploads/$model/files/$id-" . $column['name'] . '.' . $column['ext']) @@ -79,7 +80,7 @@ @endif
@endif - @elseif($column['type'] == 'display') + @elseif($type == 'display')
{{ $value }}
@endif