Add an option-select option to the set of available form items in the dashboard edit item page and document its use in the readme

This commit is contained in:
Kevin MacMartin 2016-05-18 20:05:14 -04:00
parent ebbec6119b
commit c4538a06eb
2 changed files with 20 additions and 6 deletions

View file

@ -174,6 +174,7 @@ This function should be named the same as the one above except with `Edit` at th
'columns' => [ 'columns' => [
[ 'name' => 'title', 'type' => 'text', 'label' => 'The Title' ], [ 'name' => 'title', 'type' => 'text', 'label' => 'The Title' ],
[ 'name' => 'iframe', 'type' => 'text' ], [ 'name' => 'iframe', 'type' => 'text' ],
[ 'name' => 'halign', 'type' => 'select', 'options' => [ 'left', 'center', 'right' ] ],
[ 'name' => 'story', 'type' => 'mkd' ], [ 'name' => 'story', 'type' => 'mkd' ],
[ 'name' => 'order', 'type' => 'hidden' ] [ 'name' => 'order', 'type' => 'hidden' ]
] ]
@ -199,6 +200,7 @@ The following is a list of possible `types` in the `columns` array for Editable
* `text`: Text input field for text data * `text`: Text input field for text data
* `mkd`: Markdown editor for text data containing markdown * `mkd`: Markdown editor for text data containing markdown
* `date`: Date and time selection tool for date/time data * `date`: Date and time selection tool for date/time data
* `select`: Text input via option select with possible options in an `options` array
* `hidden`: Fields that will contain values to pass to the update function but won't appear on the page (this must be used for the sort column) * `hidden`: Fields that will contain values to pass to the update function but won't appear on the page (this must be used for the sort column)
#### Edit Item Functionality #### Edit Item Functionality

View file

@ -17,8 +17,8 @@
<input type="hidden" name="_token" id="_token" value="{{ csrf_token() }}" /> <input type="hidden" name="_token" id="_token" value="{{ csrf_token() }}" />
<div class="container-fluid"> <div class="container-fluid">
<div class="row"> @foreach($columns as $column)
@foreach($columns as $column) <div class="row">
@set('value', $item[$column['name']]) @set('value', $item[$column['name']])
@if($column['type'] == 'hidden') @if($column['type'] == 'hidden')
@ -35,12 +35,24 @@
<input class="date-time-picker" type="text" name="{{ $column['name'] }}" id="{{ $column['name'] }}" value="{{ preg_replace('/:[0-9][0-9]$/', '', $value) }}" /> <input class="date-time-picker" type="text" name="{{ $column['name'] }}" id="{{ $column['name'] }}" value="{{ preg_replace('/:[0-9][0-9]$/', '', $value) }}" />
@elseif($column['type'] == 'mkd') @elseif($column['type'] == 'mkd')
<textarea class="mkd-editor" name="{{ $column['name'] }}" id="{{ $column['name'] }}" value="{{ $value }}"></textarea> <textarea class="mkd-editor" name="{{ $column['name'] }}" id="{{ $column['name'] }}" value="{{ $value }}"></textarea>
@elseif($column['type'] == 'select')
<select class="text-input" name="{{ $column['name'] }}" id="{{ $column['name'] }}">
@foreach($column['options'] as $option)
@if($option === $value)
<option value="{{ $option }}" selected="selected">{{ $option }}</option>
@else
<option value="{{ $option }}">{{ $option }}</option>
@endif
@endforeach
</select>
@endif @endif
</div> </div>
@endif @endif
@endforeach </div>
@endforeach
@if(!empty($imgup) && $imgup) @if(!empty($imgup) && $imgup)
<div class="row">
<div class="col-xs-12 col-md-2"> <div class="col-xs-12 col-md-2">
<label for="{{ $column['name'] }}">Picture:</label> <label for="{{ $column['name'] }}">Picture:</label>
</div> </div>
@ -55,8 +67,8 @@
<div>(No Image Set)</div> <div>(No Image Set)</div>
@endif @endif
</div> </div>
@endif </div>
</div> @endif
<div class="row"> <div class="row">
<button id="back" type="button" class="back-button btn btn-default">Back</button> <button id="back" type="button" class="back-button btn btn-default">Back</button>