vue-generators / vue-form-generator Goto Github PK
View Code? Open in Web Editor NEW:clipboard: A schema-based form generator component for Vue.js
License: MIT License
:clipboard: A schema-based form generator component for Vue.js
License: MIT License
Currently getting the error in the title.
Full error:
vue.common.js?4a36:1137[Vue warn]: <div v-for="field in fields" v-if="fieldVisible(field)">: Using v-if and v-for on the same element is not recommended - consider filtering the source Array instead. (found in component: <vue-form-generator>)
Am I doing something wrong?
When I use a pikaday field with no special options, I get "Invalid date" in the field.
I can see the good value for a fraction of a second but then it get replaced by this message.
This problem don't appear with the dev environment, and I suspect it has something to do with Moment.js (or the lack of it to be precise).
I experimented a bit with format
, but nothing change that.
For now I will send a PR which don't add any default values (except field
) in pikadayOptions.
I'm using vfg in another project with webpack. And vfg is marked as a fragment instance. I don't get it...
Same Vue version as the one use in the dev example.
Hi!
Is there a way to access the validation results?
The intention is to enable the disabled submit button once all validation requirements are met.
I know that there's the onValidated
method for every field, but I can't access anything other than the model
, the errors
and the field
itself and nothing from the parent component.
Is there a way to do this without hacking on the model?
And on that note... How to trigger the form validation?
it has something to do with multiSelect
option set to true.
@icebob can you explain to me how multiple work again ?
Because currently there is no vanilla datetime picker. Pickaday is only date selector.
datetime
field to datetimePicker
(break changes)slider
field to rangeSlider
(break changes)Available types
Other HTML5 types
Set this inputType to the field type attributes:
input( :type="schema.inputType")
There is a few problem with noUiSlider:
[Number, null]
. It expect us to use slider.noUiSlider.get()
. So, much like with date input, we need a formatValueToField
and formatValueToModel
to properly format data back and forth.I'm on both issue and I will do a PR in the next days.
Same as "readonly". Add to every field which contains input
element.
Example schema:
let schema = {
type: "text",
label: "E-mail",
model: "email",
readonly: false,
autocomplete: true,
placeholder: "Field placeholder"
};
Example template of field:
input.form-control(type="email", v-model="value", :readonly="schema.readonly", :disabled="disabled", :placeholder="schema.placeholder", :autocomplete="schema.autocomplete")
At once image selected on localhost text/placeholder of input changing to
Is possible to hide input with filename or just show filename?
https://jsfiddle.net/0mg1v81e/10/
I would like to create two select fields which affect each other, basically the possible values should change depending on the other field.
Is there a way to do this?
I've read the documentation on the field's general onChanged
property but I could not figure out a way to access the schema.
I don't get it, nothing seem to change when I use the option.
show this help if mouse hover the question icon before the caption of field. You can use HTML elements too.
What question mark ? How do I use HTML elements ?
Thank you for your help.
While doing the documentation for pikaday field, I noticed that the following callback are not available.
They should be added, no ?
Because with it, we can generate native submittable form too. With submit button, this named
fields can be send to server side with POST. Spec
name
attributes from schema.inputName
property to input
, select
, textarea
fieldsI removed custom-label
property from multiselect because give errors.
If it props doesn't exist in schema, multiselect try to call and gives error.
vue-form-generator.css
file. #27scoped
from stylesA very modularized version of the app would be a plus.
My goal is:
vue.js
vs vue.common.js
)I have not tested if it work. It should, but better safe than sorry.
http://refreshless.com/nouislider/pips/
I see some changes in your code from github (breaked form layout, ...) but no new release out in the tags so npm refuse to fetch the last code. Is the new code trustable?
BTW thanks for this package and keep up the good work!
I get this error when I try to use the VueFormGenerator component without passing in an options property. For example,
<template>
<vue-form-generator :schema="schema" :model="model"></vue-form-generator>
</template>
<script>
import { component as VueFormGenerator } from 'vue-form-generator';
export default {
components: {
VueFormGenerator,
},
data() {
return {
schema: {
fields: [
{ model: 'foo', type: 'number' },
],
},
model: {
foo: 3.14,
},
},
},
};
</script>
The bug is in the watch
method in src/formGenerator.vue
, where the library does not check if this.options
is truthy before checking if this.options.validateAfterLoad
is true. Reference.
There are two potential solutions to this problem: either set default values for the options
property or add an additional check for this.options
before access this.options.validateAfterLoad
.
To set a default value, the library could define its props as:
<script>
export default {
props: {
schema: Object,
options: {
type: Object,
default: {
validateAfterLoad: false,
},
},
// etc
},
};
</script>
To just add the extra check, the code would need to change from:
// Model changed!
if (this.options.validateAfterLoad === true && this.isNewModel !== true)
this.validate();
else
this.clearValidationErrors();
to:
// Model changed!
if (this.options && this.options.validateAfterLoad === true && this.isNewModel !== true)
this.validate();
else
this.clearValidationErrors();
so that it matches the line later in the same file: Reference:
// First load, running validation if neccessary
if (this.options && this.options.validateAfterLoad === true && this.isNewModel !== true)
this.validate();
else
this.clearValidationErrors();
In the doc, it say that custom fields are "coming soon". It is something very interesting.
Can you share your progress on that feature ?
Can I help you on that ?
Currently in these types the result is true or false.
Need to add onValue, offValue options to fieldSwitch and add trueValue and falseValue to fieldCheckbox. After it the fields can toggle 0/1, or "yes"/"no" values too
Add:
This is another mental note to implement a graceful destruction of component that initialize event listening.
Concerned component:
Maybe also:
Create fields with vanilla libs which have no jQuery and Bootstrap dependencies.
For these developments I created an independent
branch. Every PR needs to add to this branch.
https://github.com/icebob/vue-form-generator/tree/independent
https://travis-ci.org/icebob/vue-form-generator/jobs/165632420
TOTAL: 3 FAILED, 370 SUCCESS
1) should contain option elements
fieldVueMultiSelect.vue check template
expected '' to equal 'Paris'
AssertionError
assert
assertEqual
2) input value should be the model value after changed
fieldVueMultiSelect.vue check template
AssertionError: expected '' to equal 'Rome' (undefined:111)
3) input value should be the model value after changed (multiselection)
fieldVueMultiSelect.vue check template
AssertionError: expected '' to equal 'Paris' (undefined:111)
Hi,
i found your very usefull library, but unfortunatelly i cant found a way to implement a simple submit button, or prevent the default event.
I use for now a form tag which is wrapping the vue-form-generator component, and inside i create manually a submit button.
But i think it would be cool if we can add a new type "submit" in the schema, but maybe there is reasons if this not exists...
Thanks, and sorry for the mystakes.
Like the dev example with all supported fields.
[12:50:41] gulp-notify: [Laravel Elixir] Browserify Failed!: Cannot find module '!!./../../node_modules/css-loader/index.js!./../../node_modules/vue-loader/lib/style-rewriter.js?id=_v-c65c5786&scoped=true!./../../node_modules/sass-loader/index.js!./../../node_modules/vue-loader/lib/selector.js?type=style&index=0!./fieldCheckbox.vue' from '/node_modules/vue-form-generator/dist'
Since featured
is entirely visual (as far as I understand), and that styleClasses
exist, featured
is a bit useless, no ?
This is a bit of nitpicking I guess, sorry if it bother you.
@lionel-bijaoui could you check this problem?
Reproduction:
Fields description should have a "default" column.
Concerned fields:
Some field component have multiple top-level elements. This will create fragment instance that should be avoided.
Concerned fields:
staticMap don't work in the dev example because geo data is defined with latitude
and longitude
properties.
Maybe it need a staticMapOptions
with properties to map to the good value:
{
type: "staticMap",
label: "Map",
model: "address.geo",
staticMapOptions: {
lat: "latitude",
lng: "longitude",
sizeX:600,
sizeY:300
}
}
edit: size param too
How can I transfer localization for a validator in the component?
Let's not forget about this, the web is for everybody.
I don't have experience with this, it could be nice to have someone who know about these stuff on board to help.
We could start with labels.
Documentation and information:
Hello,
I was wandering if it could be possible to use less dependency or smaller, more focused one. For example, what is the use of jQuery ? Why Bootstrap ?
It is something that is actually stopping me from using this component, because I don't want to bloat my web app with jQuery and Bootstrap. It's a shame really because I really need the functionality provided by your component.
Also, I could be awesome if we could choose the kind of input in a more modular way.
For example, if I don't use range slider fields, I could avoid ion.rangeSlider. If I want to use noUiSlider instead, I could create a new submodule easily. It seem to be already possible, but I wanted to be sure.
I'm ready to help, if you think this is technically possible.
Thank you for your hard work.
It would be great to have conditional fields. The value of one field influence others visibility (and maybe more ?).
For example, I check a checkbox field, and it show another field.
It could allow for very dynamic forms.
The field would need some sort of meta information about them, for example:
/*schema.js*/
fields: [{
type: "switch",
label: "Add a packaging ?",
model: "packet"
}, {
type: "select",
label: "packet type",
model: "packet_type",
required: true,
values: [
{ id: "standard", name: "Standard" },
{ id: "present", name: "Present" }
]
// Only appear if packet value is true
dependOn: [{ model: "packet", value: true }]
}, {
type: "text",
label: "message to write on the note",
model: "present_note",
// Only appear if packet_type selected value of "id" field is "present" AND if packet value is true
dependOn: [{ model: "packet_type", field: "id", value: "present" }, { model: "packet", value: true }]
}]
They could be option for "not this value" and "multiple good values".
Internally, it could use v-show on a computed value that we could add in abstractField.js.
That's just some first ideas and thoughts, please tell me what are you think about that.
I guess it going to be hard to do, but this is something necessary.
2.0 changes
.sync
My first analysis point to one real problem, the disappearance of .sync
.
so instead of:
:model.sync="model", :schema.sync="field"
We should do:
:model="model", :schema="field", @model-updated="modelUpdated", @schema-updated="schemaUpdated"
and inside the fields (abstractField.js)
props: ["model", "schema"],
watch: {
model(newVal) {
this.$emit('model-updated', newValue)
},
schema(newVal) {
this.$emit('schema-updated', newValue)
}
}
Also change formGenerator.vue:
watch: {
// new model loaded
model: function(newModel, oldModel) {
if (oldModel == newModel) // model got a new property
return;
//console.log("Model changed!");
if (this.options.validateAfterLoad === true && this.isNewModel !== true)
this.validate();
else
this.clearValidationErrors();
}
}
to
methods: {
modelUpdated: function(newModel){
if (this.model == newModel) // model got a new property
return;
//console.log("Model changed!");
if (this.options.validateAfterLoad === true && this.isNewModel !== true)
this.validate();
else
this.clearValidationErrors();
}
}
This need to be tested.
Another thing could be related to ready
becoming mounted
. There's no longer the guarantee to be in-document and could break most js dependent fields.
We should test if the component is in document ourself now. I have no idea how to do that.
Maybe check if vm.$el
have a parent ? And if not use a small setTimeout to lauch the test again soon ?
I'm sure I'm missing a lot of problem, but this seem achievable.
What are your thought ?
When I create a select box, it will put this inside it:
<Not selected>
Why is this exactly? I would like it to see that it will add my placeholder to the element. Also, languagewise this is conflicting with me, I am dutch and thus anther language would be nice. (Maybe optional when adding such a field)
I was checking attributes in the doc and unit test when I realized that.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.