if (!$this->_plural) {
$this->_plural = $this->_singular . 's';
}
+
if ($this->_clonable) {
$this->crud->allowAccess('clone');
}
$this->crud->allowAccess('revisions');
+
+ $this->crud->setCreateView('cubist_back::create');
+ $this->crud->setEditView('cubist_back::edit');
// $this->crud->with('revisionHistory');
'template_plural' => 'templates',
'parent' => 'Parent',
'field_singular' => 'Field',
- 'field_plural' => 'Fields'
+ 'field_plural' => 'Fields',
+ 'first_value' => 'First value',
+ 'second_value' => 'Second value'
];
--- /dev/null
+@push('crud_fields_scripts')
+ <script type="text/javascript">
+ jQuery('document').ready(function ($) {
+ var triggersWhenChange = function (f) {
+ var form;
+ if (f === undefined) {
+ form = $('section.content form[method="post"]');
+ } else {
+ form = $(f).closest('form');
+ }
+
+ $(form).find('[data-when]').removeClass('when-visible').each(function () {
+ var conditions = $(this).data('when');
+ var match = true;
+ $.each(conditions, function (k, v) {
+ var val = $(form).find('[name="' + k + '"]').val();
+ var valnum = parseFloat(val);
+ if (!isNumber(valnum)) {
+ valnum = val;
+ }
+ if (v.indexOf(val) === -1 && v.indexOf(valnum) === -1) {
+ match = false;
+ return false;
+ }
+ });
+
+ if (match) {
+ $(this).addClass('when-visible');
+ }
+ });
+ };
+
+ function isNumber(n) {
+ return typeof n === 'number' && !isNaN(n);
+ }
+
+ $(document).on('change', 'input,select,textarea', function () {
+ triggersWhenChange($(this));
+ });
+ triggersWhenChange();
+ });
+
+ </script>
+@endpush
+
+@push('crud_fields_styles')
+ <style type="text/css">
+ [data-when] {
+ display: none;
+ }
+
+ .when-visible[data-when] {
+ display: block;
+ }
+ </style>
+@endpush