mirror of
https://github.com/prurigro/hypothetical.git
synced 2024-11-21 15:42:31 -05:00
Add in functionality to set a different column type on creation than when being edited
This commit is contained in:
parent
3545378192
commit
256c0b179a
2 changed files with 12 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -20,26 +20,27 @@
|
|||
@foreach($columns as $column)
|
||||
<div class="row">
|
||||
@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')
|
||||
<input class="text-input" type="hidden" name="{{ $column['name'] }}" id="{{ $column['name'] }}" value="{{ $value }}" />
|
||||
@elseif($column['type'] == 'user')
|
||||
@elseif($type == 'user')
|
||||
<input class="text-input" type="hidden" name="{{ $column['name'] }}" id="{{ $column['name'] }}" value="{{ Auth::id() }}" />
|
||||
@elseif($column['type'] != 'display' || $id != 'new')
|
||||
@elseif($type != 'display' || $id != 'new')
|
||||
<div class="col-12 col-md-2">
|
||||
<label for="{{ $column['name'] }}">{{ array_key_exists('title', $column) ? $column['title'] : ucfirst($column['name']) }}:</label>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-10">
|
||||
@if($column['type'] == 'text')
|
||||
@if($type == 'text')
|
||||
<input class="text-input" type="text" name="{{ $column['name'] }}" id="{{ $column['name'] }}" value="{{ $value }}" />
|
||||
@elseif($column['type'] == 'date')
|
||||
@elseif($type == 'date')
|
||||
<input class="date-picker" type="text" name="{{ $column['name'] }}" id="{{ $column['name'] }}" value="{{ $value == '' ? date('Y-m-d', time()) : preg_replace('/:[0-9][0-9]$/', '', $value) }}" />
|
||||
@elseif($column['type'] == 'mkd')
|
||||
@elseif($type == 'mkd')
|
||||
<div class="mkd-editor-container">
|
||||
<textarea class="mkd-editor" name="{{ $column['name'] }}" id="{{ $column['name'] }}" value="{{ $value }}"></textarea>
|
||||
</div>
|
||||
@elseif($column['type'] == 'select')
|
||||
@elseif($type == 'select')
|
||||
<select class="text-input" name="{{ $column['name'] }}" id="{{ $column['name'] }}">
|
||||
@foreach($column['options'] as $option)
|
||||
@if($option === $value)
|
||||
|
@ -49,7 +50,7 @@
|
|||
@endif
|
||||
@endforeach
|
||||
</select>
|
||||
@elseif($column['type'] == 'image')
|
||||
@elseif($type == 'image')
|
||||
@set('current_image', "/uploads/$model/img/$id-" . $column['name'] . '.jpg')
|
||||
<input class="image-upload" type="file" name="{{ $column['name'] }}" id="{{ $column['name'] }}" />
|
||||
|
||||
|
@ -64,7 +65,7 @@
|
|||
@endif
|
||||
</div>
|
||||
@endif
|
||||
@elseif($column['type'] == 'file')
|
||||
@elseif($type == 'file')
|
||||
@set('current_file', "/uploads/$model/files/$id-" . $column['name'] . '.' . $column['ext'])
|
||||
<input class="file-upload" type="file" name="{{ $column['name'] }}" id="{{ $column['name'] }}" data-ext="{{ $column['ext'] }}" />
|
||||
|
||||
|
@ -79,7 +80,7 @@
|
|||
@endif
|
||||
</div>
|
||||
@endif
|
||||
@elseif($column['type'] == 'display')
|
||||
@elseif($type == 'display')
|
||||
<div class="text-display">{{ $value }}</div>
|
||||
@endif
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue