protected $_ajax = true;
protected $_allowsHTML = false;
+ protected $_showSeletedOption = 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, 'allows_html' => $this->_allowsHTML]);
+ 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, 'show_selected_option' => $this->_showSeletedOption]);
}
protected function _postSetAttributes()
@endif
</select>
+@if($field['show_selected_option'])
+ <p class="help-block">{{__('Valeur actuelle : ')}} <span class="selectFromArrayCurrentValue"></span></p>
+@endif
{{-- HINT --}}
@if (isset($field['hint']))
<p class="help-block">{!! $field['hint'] !!}</p>
@endif
+
+
@include('crud::fields.inc.wrapper_end')
{{-- ########################################## --}}
initUntriggeredSelectFromArray($);
});
initUntriggeredSelectFromArray($);
+
+ $(document).on('change', '.select2_from_array', function () {
+ showSelectedValue();
+ });
});
+ function showSelectedValue() {
+ $('.selectFromArrayCurrentValue').each(function () {
+ let v = $(this).closest('.form-group').find('select').val();
+ $(this).text(v);
+ });
+ }
+
function initUntriggeredSelectFromArray($) {
// trigger select2 for each untriggered select2 box
$('.select2_from_array:not(.select2-hidden-accessible)').each(function (i, obj) {
}
$(obj).addClass('init').select2(options);
});
+ showSelectedValue();
}
</script>
@endpush