mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-24 02:04:04 +08:00
Merge pull request #19971 from dannon/trim-pref-inputs
Adds a trimInputs prop to FormGeneric to trim string values on submit.
This commit is contained in:
@@ -72,6 +72,10 @@ export default {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
trimInputs: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -103,7 +107,18 @@ export default {
|
||||
window.location = withPrefix(this.cancelRedirect);
|
||||
},
|
||||
onSubmit() {
|
||||
submitData(this.url, this.formData).then((response) => {
|
||||
const formData = { ...this.formData };
|
||||
|
||||
if (this.trimInputs) {
|
||||
// Trim string values in form data
|
||||
Object.keys(formData).forEach((key) => {
|
||||
if (typeof formData[key] === "string") {
|
||||
formData[key] = formData[key].trim();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
submitData(this.url, formData).then((response) => {
|
||||
let params = {};
|
||||
if (response.id) {
|
||||
params.id = response.id;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<FormGeneric v-bind="formConfig" />
|
||||
<FormGeneric v-bind="formConfig" :trim-inputs="true" />
|
||||
</template>
|
||||
<script>
|
||||
import FormGeneric from "components/Form/FormGeneric";
|
||||
|
||||
Reference in New Issue
Block a user