Skip to content

Commit

Permalink
Selectbox add new and validation message.
Browse files Browse the repository at this point in the history
  • Loading branch information
cuneytsenturk committed Mar 7, 2020
1 parent 3f80aa1 commit fd25e31
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
39 changes: 38 additions & 1 deletion resources/assets/js/components/AkauntingSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ import { Select, Option, OptionGroup, ColorPicker } from 'element-ui';
import AkauntingModalAddNew from './AkauntingModalAddNew';
import AkauntingModal from './AkauntingModal';
import AkauntingMoney from './AkauntingMoney';
import AkauntingRadioGroup from './forms/AkauntingRadioGroup';
import AkauntingSelect from './AkauntingSelect';
import AkauntingDate from './AkauntingDate';
Expand All @@ -412,6 +413,7 @@ export default {
AkauntingRadioGroup,
AkauntingSelect,
AkauntingModal,
AkauntingMoney,
AkauntingDate,
AkauntingRecurring,
},
Expand Down Expand Up @@ -584,6 +586,7 @@ export default {
AkauntingRadioGroup,
AkauntingSelect,
AkauntingModal,
AkauntingMoney,
AkauntingDate,
AkauntingRecurring,
[ColorPicker.name]: ColorPicker,
Expand Down Expand Up @@ -618,7 +621,41 @@ export default {
onSubmit(event) {
this.form = event;
axios.post(this.form.action, this.form.data())
this.loading = true;
let data = this.form.data();
FormData.prototype.appendRecursive = function(data, wrapper = null) {
for(var name in data) {
if (wrapper) {
if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
this.appendRecursive(data[name], wrapper + '[' + name + ']');
} else {
this.append(wrapper + '[' + name + ']', data[name]);
}
} else {
if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
this.appendRecursive(data[name], name);
} else {
this.append(name, data[name]);
}
}
}
};
let form_data = new FormData();
form_data.appendRecursive(data);
window.axios({
method: this.form.method,
url: this.form.action,
data: form_data,
headers: {
'X-CSRF-TOKEN': window.Laravel.csrfToken,
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'multipart/form-data'
}
})
.then(response => {
this.form.loading = false;
Expand Down
34 changes: 33 additions & 1 deletion resources/assets/js/components/AkauntingSelectRemote.vue
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,39 @@ export default {
onSubmit(event) {
this.form = event;
axios.post(this.form.action, this.form.data())
let data = this.form.data();
FormData.prototype.appendRecursive = function(data, wrapper = null) {
for(var name in data) {
if (wrapper) {
if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
this.appendRecursive(data[name], wrapper + '[' + name + ']');
} else {
this.append(wrapper + '[' + name + ']', data[name]);
}
} else {
if ((typeof data[name] == 'object' || data[name].constructor === Array) && ((data[name] instanceof File != true ) && (data[name] instanceof Blob != true))) {
this.appendRecursive(data[name], name);
} else {
this.append(name, data[name]);
}
}
}
};
let form_data = new FormData();
form_data.appendRecursive(data);
window.axios({
method: this.form.method,
url: this.form.action,
data: form_data,
headers: {
'X-CSRF-TOKEN': window.Laravel.csrfToken,
'X-Requested-With': 'XMLHttpRequest',
'Content-Type': 'multipart/form-data'
}
})
.then(response => {
this.form.loading = false;
Expand Down
4 changes: 2 additions & 2 deletions resources/views/partials/form/select_group.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class="{{ $col }}{{ isset($attributes['required']) ? ' required' : '' }}{{ isset
@if (!empty($attributes['v-error']))
:form-classes="[{'has-error': {{ $attributes['v-error'] }} }]"
@else
:form-classes="[{'has-error': form.errors.get('{{ $name }}') }]"
:form-classes="[{'has-error': form.errors.has('{{ $name }}') }]"
@endif

icon="{{ $icon }}"
Expand All @@ -28,7 +28,7 @@ class="{{ $col }}{{ isset($attributes['required']) ? ' required' : '' }}{{ isset
@elseif (!empty($attributes['data-field']))
@interface="{{ 'form.' . $attributes['data-field'] . '.' . $name . ' = $event' }}"
@else
@interface="form.{{ $name }} = $event"
@interface="form.errors.clear('{{ $name }}'); form.{{ $name }} = $event;"
@endif

@if (!empty($attributes['change']))
Expand Down

0 comments on commit fd25e31

Please sign in to comment.