FEATURE #1368: add form for creating new custom field
Currently, form is not saved, however it is validated.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Requests\NewCustomFieldRequest;
|
||||
|
||||
class CreateNewCustomField extends Controller
|
||||
{
|
||||
public function getNew()
|
||||
{
|
||||
$types = [];
|
||||
|
||||
return view('admin.customFields.new', ['types' => $types]);
|
||||
}
|
||||
|
||||
public function postNew(NewCustomFieldRequest $request)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Requests;
|
||||
|
||||
class NewCustomFieldRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'name' => 'required',
|
||||
'type' => 'required|exists:custom_field_types',
|
||||
'minLength' => 'numeric|min:0',
|
||||
'maxLength' => 'numeric|mix:0'
|
||||
];
|
||||
}
|
||||
}
|
||||
+11
-2
@@ -48,11 +48,20 @@ Route::group([
|
||||
Route::get('users/overview/{state?}', 'UsersOverview@getOverview')
|
||||
->name('users.overview');
|
||||
|
||||
|
||||
// custom fields
|
||||
// ------------------------------
|
||||
Route::get('customfields/overview', 'CustomFieldsOverview@getOverview')->name('customfields.overview');
|
||||
|
||||
// list of all custom fields
|
||||
Route::get('customfields/overview', 'CustomFieldsOverview@getOverview')
|
||||
->name('customfields.overview');
|
||||
|
||||
// form for adding new custom field
|
||||
Route::get('customfields/new', 'CreateNewCustomField@getNew')
|
||||
->name('customfields.new');
|
||||
|
||||
// form for adding new custom field
|
||||
Route::post('customfields/new', 'CreateNewCustomField@postNew')
|
||||
->name('customfields.newPost');
|
||||
|
||||
// logout method
|
||||
Route::get('logout', function () {
|
||||
|
||||
@@ -33,7 +33,8 @@ class AdminMenusProvider extends ServiceProvider
|
||||
|
||||
}, 20, ['icon' => 'fa fa-users']);
|
||||
$menu->dropdown(trans('admin/mainMenu.customFields'), function ($sub) {
|
||||
$sub->route('customfields.overview', trans('admin/mainMenu/customFieldsOverview'), [], 50, ['icon' => 'fa code-fork']);
|
||||
$sub->route('customfields.new', trans('admin/mainMenu.customFieldsNew'), [], 10, ['icon' => 'fa fa-code']);
|
||||
$sub->route('customfields.overview', trans('admin/mainMenu.customFieldsOverview'), [], 50, ['icon' => 'fa fa-code-fork']);
|
||||
}, 30, ['icon' => 'fa fa-code']);
|
||||
$menu->url('#', trans('admin/mainMenu.settings'), 50, ['icon' => 'fa fa-gear']);
|
||||
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
<?php
|
||||
return [
|
||||
'overview' => 'List of all custom fields',
|
||||
'noFields' => 'No custom fields defined.',
|
||||
'users' => 'Custom fields for user',
|
||||
'content' => 'Custom fields for content page',
|
||||
'overview' => 'List of all custom fields',
|
||||
'new' => 'New custom field',
|
||||
'noFields' => 'No custom fields defined.',
|
||||
'users' => 'Custom fields for user',
|
||||
'content' => 'Custom fields for content page',
|
||||
'name' => 'Name',
|
||||
'description' => 'Description',
|
||||
'type' => 'Type of custom field',
|
||||
'required' => 'Is field required?',
|
||||
'defaultValue' => 'Default value',
|
||||
'regExp' => 'Match only this regular expression',
|
||||
'minLength' => 'Minimum length',
|
||||
'maxLength' => 'Maximum length',
|
||||
'createNew' => 'Create new field'
|
||||
];
|
||||
@@ -7,6 +7,7 @@ return [
|
||||
'usersOverview' => 'Overview',
|
||||
'userDetail' => 'Detail',
|
||||
'customFields' => 'Custom fields',
|
||||
'customFieldsOverview' => 'Overvview',
|
||||
'customFieldsOverview' => 'Overview',
|
||||
'customFieldsNew' => 'New field',
|
||||
'settings' => 'Settings'
|
||||
];
|
||||
@@ -0,0 +1,15 @@
|
||||
@extends('admin.layout')
|
||||
|
||||
@section('pageName', @trans('admin/customFields.new'))
|
||||
|
||||
@section('content')
|
||||
|
||||
<div class="row">
|
||||
<h2>@lang('admin/customFields.new')</h2>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
@include('admin.customFields.newForm')
|
||||
</div>
|
||||
@stop
|
||||
@@ -0,0 +1,79 @@
|
||||
<form method="POST" action="{{route('customfields.newPost')}}">
|
||||
{!! csrf_field() !!}
|
||||
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<label>
|
||||
@lang('admin/customFields.name')
|
||||
<input type="text" placeholder="@lang('admin/customFields.name')" name="name">
|
||||
|
||||
@if (isset($errors) && $errors->has('name'))
|
||||
<div class="callout alert">
|
||||
{{ $errors->first('name') }}
|
||||
</div>
|
||||
@endif
|
||||
</label>
|
||||
</div>
|
||||
<div class="large-6 columns">
|
||||
<label>
|
||||
@lang('admin/customFields.type')
|
||||
|
||||
<select name="type">
|
||||
@foreach($types as $type => $translation)
|
||||
<option value="{{$type}}">@lang($translation)</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<label>
|
||||
@lang('admin/customFields.description')
|
||||
|
||||
<textarea rows="5" name="description" placeholder="@lang('admin/customFields.description')"></textarea>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="large-6 columns">
|
||||
<label>
|
||||
@lang('admin/customFields.required')
|
||||
|
||||
<input type="checkbox" placeholder="@lang('admin/customFields.required')" name="required">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
@lang('admin/customFields.defaultValue')
|
||||
|
||||
<input type="text" placeholder=" @lang('admin/customFields.defaultValue')" defaultValue">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
@lang('admin/customFields.regExp')
|
||||
|
||||
<input type="text" placeholder="@lang('admin/customFields.regExp')" name="regExp">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="large-6 columns">
|
||||
<label>
|
||||
@lang('admin/customFields.minLength')
|
||||
|
||||
<input type="text" placeholder="@lang('admin/customFields.minLength')"name="minLength">
|
||||
</label>
|
||||
</div>
|
||||
<div class="large-6 columns">
|
||||
<label>
|
||||
@lang('admin/customFields.maxLength')
|
||||
|
||||
<input type="text" placeholder="@lang('admin/customFields.maxLength')"name="maxLength">
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label>
|
||||
<button type="submit" class="button success">@lang('admin/customFields.createNew')</button>
|
||||
</label>
|
||||
</form>
|
||||
Reference in New Issue
Block a user