*/
public function boot()
{
-
-
$base = realpath(__DIR__ . "/..");
$resourcesDir = $base . '/resources';
return "<?php echo \$__env->make('" . self::NAMESPACE . "::favicon', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>";
});
-
$this->app->extend('crud', function () {
return new CubistCrudPanel();
});
$base = realpath(__DIR__ . "/..");
$resourcesDir = $base . '/resources';
-
$configs = ['app', 'cubist'];
foreach ($configs as $config) {
$this->mergeConfigFrom($resourcesDir . '/config/' . $config . '.php', $config);
}
-
$this->commands([
InstallCommand::class,
UpdateCommand::class,
protected $_options_aliases = [];
protected $_filterType = 'dropdown';
protected $_ajax = true;
+ protected $_allowsHTML = false;
public function getDefaultAttributes()
{
- return array_merge(parent::getDefaultAttributes(), ['options' => $this->getOptions(), 'options_aliases' => $this->_options_aliases, 'allows_null' => $this->_allowNull, 'allows_multiple' => $this->_multiple, 'ajax' => $this->_ajax]);
+ return array_merge(parent::getDefaultAttributes(), ['options' => $this->getOptions(), 'options_aliases' => $this->_options_aliases, 'allows_null' => $this->_allowNull, 'allows_multiple' => $this->_multiple, 'ajax' => $this->_ajax, 'allows_html' => $this->_allowsHTML]);
}
protected function _postSetAttributes()
}
$ajax=isset($field['ajax']) && $field['ajax'];
+ $allows_html=isset($field['allows_html']) && $field['allows_html'];
if($ajax){
$field['ajax']=\Cubist\Backpack\Magic\Fields\SelectFromArray::hashOptions($field['options']);
}
@endphp
-<!-- select2 from array -->
+ <!-- select2 from array -->
@include('crud::fields.inc.wrapper_start')
<label>{!! $field['label'] !!}</label>
@if (isset($field['allows_multiple']) && $field['allows_multiple']==true)
@include('crud::fields.inc.attributes', ['default_class' => 'form-control select2_from_array'])
@if (isset($field['allows_multiple']) && $field['allows_multiple']==true)multiple @endif
@if($ajax) data-ajax="{{$field['ajax']}}" @endif
+ @if($allows_html) data-allow-html="1" @endif
>
@if (isset($field['allows_null']) && $field['allows_null']==true)
@if($is_null)
@endphp
@if($selected)
<option value="{{ $key }}" selected>{{ $value }}</option>
- @else if(!$ajax)
- <option value="{{ $key }}">{{ $value }}</option>
+ @elseif(!$ajax)
+ <option value="{{ $key }}">{{ $value }}</option>
@endif
@endforeach
@endif
<script>
jQuery(document).ready(function ($) {
$(document).on('cubist.bunchmultiple.added', function () {
- initUntriggeredSelectFromArray();
+ initUntriggeredSelectFromArray($);
});
- initUntriggeredSelectFromArray();
+ initUntriggeredSelectFromArray($);
+ });
- function initUntriggeredSelectFromArray() {
- // trigger select2 for each untriggered select2 box
- $('.select2_from_array:not(.select2-hidden-accessible)').each(function (i, obj) {
- if ($(obj).closest('.item.sample').length > 0) {
- return;
- }
- var options = {
- theme: "bootstrap",
+ function initUntriggeredSelectFromArray($) {
+ // trigger select2 for each untriggered select2 box
+ $('.select2_from_array:not(.select2-hidden-accessible)').each(function (i, obj) {
+ if ($(obj).closest('.item.sample').length > 0) {
+ return;
+ }
+ var options = {
+ theme: "bootstrap",
+ };
+ if ($(this).is('[data-ajax]')) {
+ options.ajax = {
+ url: '{{backpack_url('select2')}}' + '/' + $(this).data('ajax'),
+ dataType: 'json',
+ delay: 250,
};
- if ($(this).is('[data-ajax]')) {
- options.ajax = {
- url: '{{backpack_url('select2')}}' + '/' + $(this).data('ajax'),
- dataType: 'json',
- delay: 250,
- };
+ }
+ if ($(this).is('[data-allow-html="1"]')) {
+ options.escapeMarkup = function (m) {
+ return m;
}
- $(obj).addClass('init').select2(options);
- });
- }
- });
-
+ }
+ $(obj).addClass('init').select2(options);
+ });
+ }
</script>
@endpush