Added optional help text field to custom fields

This commit is contained in:
snipe 2017-01-26 04:52:11 -08:00
parent b0f84fa82b
commit b4c6d0c897
4 changed files with 32 additions and 6 deletions

View file

@ -72,10 +72,11 @@ class CustomFieldsController extends Controller
public function store(Request $request) public function store(Request $request)
{ {
$field = new CustomField([ $field = new CustomField([
"name" => e($request->get("name")), "name" => $request->get("name"),
"element" => e($request->get("element")), "element" => $request->get("element"),
"field_values" => e($request->get("field_values")), "help_text" => $request->get("help_text"),
"field_encrypted" => e($request->get("field_encrypted", 0)), "field_values" => $request->get("field_values"),
"field_encrypted" => $request->get("field_encrypted", 0),
"user_id" => Auth::user()->id "user_id" => Auth::user()->id
]); ]);
@ -87,6 +88,7 @@ class CustomFieldsController extends Controller
$field->format = e($request->get("format")); $field->format = e($request->get("format"));
} }
$validator = Validator::make(Input::all(), $field->rules); $validator = Validator::make(Input::all(), $field->rules);
if ($validator->passes()) { if ($validator->passes()) {
@ -176,6 +178,7 @@ class CustomFieldsController extends Controller
$field->field_values = e($request->get("field_values")); $field->field_values = e($request->get("field_values"));
$field->field_encrypted = e($request->get("field_encrypted", 0)); $field->field_encrypted = e($request->get("field_encrypted", 0));
$field->user_id = Auth::user()->id; $field->user_id = Auth::user()->id;
$field->help_text = $request->get("help_text");
if (!in_array(Input::get('format'), array_keys(CustomField::$PredefinedFormats))) { if (!in_array(Input::get('format'), array_keys(CustomField::$PredefinedFormats))) {
$field->format = e($request->get("custom_format")); $field->format = e($request->get("custom_format"));

View file

@ -87,7 +87,20 @@
</div> </div>
</div> </div>
@if (!$field->id) <!-- Help Text -->
<div class="form-group {{ $errors->has('help_text') ? ' has-error' : '' }}">
<label for="help_text" class="col-md-4 control-label">
Help Text
</label>
<div class="col-md-6">
{{ Form::text('help_text', Input::old('help_text', $field->help_text), array('class' => 'form-control')) }}
<p class="help-block">This is optional text that will appear below the form elements while editing an asset to provide context on the field.</p>
{!! $errors->first('help_text', '<span class="alert-msg"><i class="fa fa-times"></i> :message</span>') !!}
</div>
</div>
@if (!$field->id)
<!-- Encrypted --> <!-- Encrypted -->
<div class="form-group {{ $errors->has('custom_format') ? ' has-error' : '' }}"> <div class="form-group {{ $errors->has('custom_format') ? ' has-error' : '' }}">
<div class="col-md-8 col-md-offset-4"> <div class="col-md-8 col-md-offset-4">

View file

@ -85,6 +85,8 @@
<thead> <thead>
<tr> <tr>
<th>{{ trans('general.name') }}</th> <th>{{ trans('general.name') }}</th>
<th>Help Text</th>
<th>DB Field</th>
<th>{{ trans('admin/custom_fields/general.field_format') }}</th> <th>{{ trans('admin/custom_fields/general.field_format') }}</th>
<th>{{ trans('admin/custom_fields/general.field_element_short') }}</th> <th>{{ trans('admin/custom_fields/general.field_element_short') }}</th>
<th>{{ trans('admin/custom_fields/general.fieldsets') }}</th> <th>{{ trans('admin/custom_fields/general.fieldsets') }}</th>
@ -92,9 +94,11 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@foreach($custom_fields AS $field) @foreach($custom_fields as $field)
<tr> <tr>
<td>{{ $field->name }}</td> <td>{{ $field->name }}</td>
<td>{{ $field->help_text }}</td>
<td>{{ $field->convertUnicodeDbSlug() }}</td>
<td>{{ $field->format }}</td> <td>{{ $field->format }}</td>
<td>{{ $field->element }}</td> <td>{{ $field->element }}</td>
<td> <td>

View file

@ -43,6 +43,10 @@
@endif @endif
@if ($field->help_text!='')
<p class="help-block">{{ $field->help_text }}</p>
@endif
<?php <?php
$errormessage=$errors->first($field->db_column_name()); $errormessage=$errors->first($field->db_column_name());
if ($errormessage) { if ($errormessage) {
@ -57,6 +61,8 @@
<i class="fa fa-lock" data-toggle="tooltip" data-placement="top" title="{{ trans('admin/custom_fields/general.value_encrypted') }}"></i> <i class="fa fa-lock" data-toggle="tooltip" data-placement="top" title="{{ trans('admin/custom_fields/general.value_encrypted') }}"></i>
</div> </div>
@endif @endif
</div> </div>
@endforeach @endforeach
@endif @endif