*/
public function boot()
{
- $this->loadTranslationsFrom(__DIR__ . '/resources/lang', self::NAMESPACE);
+ $this->loadTranslationsFrom(realpath(__DIR__ . '/resources/lang'), self::NAMESPACE);
foreach (glob(__DIR__ . '/routes/cubist/backpack/*.php') as $filename) {
$this->loadRoutesFrom($filename);
}
--- /dev/null
+<?php
+
+
+namespace Cubist\Backpack\app\Magic\Fields;
+
+
+class Integer extends Number
+{
+ protected $_step = 1;
+}
protected $_adminType = 'number';
protected $_databaseType = 'float';
protected $_columnType = 'number';
+ protected $_step = 'any';
+ protected $_min = null;
+ protected $_max = null;
+
+ public function getDefaultAttributes()
+ {
+ $res = parent::getDefaultAttributes();
+ $attrs = ['min', 'max', 'step'];
+ $defaults = [];
+ foreach ($attrs as $attr) {
+ if (null === $this->{'_' . $attr}) {
+ continue;
+ }
+ $defaults[$attr] = $this->{'_' . $attr};
+ }
+
+ $res['attributes'] = array_merge($defaults, $res['attributes']);
+ return $res;
+ }
}
use Cubist\Backpack\CubistBackpackServiceProvider;
-class Range extends Field
+class Range extends Number
{
protected $_adminType = 'rangeofvalues';
protected $_viewNamespace = CubistBackpackServiceProvider::NAMESPACE . '::fields';
+
+ public function getDefaultAttributes()
+ {
+ $res = parent::getDefaultAttributes();
+ $res['first_label'] = trans('cubist_back::first_value');
+ $res['second_label'] = trans('cubist_back::second_value');
+ return $res;
+ }
}
--- /dev/null
+<?php
+
+return [
+ /*
+ |--------------------------------------------------------------------------
+ | Templates Language Lines
+ |--------------------------------------------------------------------------
+ |
+ | The following language lines are used for Cubist backpack
+ |
+ */
+ 'first_value' => 'First value',
+ 'second_value' => 'Second value'
+];
-<!-- field_type_name -->
+<!-- range of values -->
<div @include('crud::inc.field_wrapper_attributes') >
<label>{!! $field['label'] !!}</label>
- <div @include('crud::inc.field_attributes')>
- <input
- type="text"
- name="{{ $field['name'] }}[min]"
- >
- <input
- type="text"
- name="{{ $field['name'] }}[max]"
- >
+ <div class="rangeofvalues__wrapper">
+ <div class="rangeofvalues__field">
+ <label>{!! $field['first_label'] !!}</label>
+ <input @include('crud::inc.field_attributes')
+ type="text"
+ name="{{ $field['name'] }}[min]"
+ >
+ </div>
+ <div class="rangeofvalues__field">
+ <label>{!! $field['second_label'] !!}</label>
+ <input @include('crud::inc.field_attributes')
+ type="text"
+ name="{{ $field['name'] }}[max]"
+ >
+ </div>
</div>
{{-- HINT --}}
{{-- push things in the after_styles section --}}
@push('crud_fields_styles')
- <!-- no styles -->
+ <style type="text/css">
+ .rangeofvalues__wrapper {
+ width: 100%;
+ white-space: nowrap;
+ }
+
+ .rangeofvalues__field {
+ width: 50%;
+ display: inline-block;
+ padding: 0 15px;
+ box-sizing: border-box;
+ }
+
+ .rangeofvalues__field label{
+ font-weight: 400;
+ }
+
+ .rangeofvalues__field:first-child {
+ padding-left: 0;
+ }
+
+ .rangeofvalues__field:last-child {
+ padding-right: 0;
+ }
+ </style>
@endpush
{{-- FIELD EXTRA JS --}}