Skip to content

Commit 05e226e

Browse files
committed
added manual layout
1 parent 45f789b commit 05e226e

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/components/FormlyForm.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
<template>
22
<fieldset>
3+
<template v-if="!customLayout">
34
<formly-field v-for="field in form | formlyFields" :form.sync="form" :key="field" ></formly-field>
5+
</template>
6+
<slot></slot>
47
</fieldset>
58
</template>
69

710
<script>
811
export default {
9-
props: ['form'],
12+
props: ['form', 'customLayout'],
1013
created(){
1114
//make sure that the 'value' is always set
1215
Object.keys(this.form).forEach((key) => {

test/unit/specs/FormlyForm.spec.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,5 +132,27 @@ describe('FormlyForm', () => {
132132
done();
133133
});
134134
});
135+
136+
it('should allow a manual display', () => {
137+
138+
Vue.component('formly-field',{
139+
props: ['form', 'key'],
140+
template: '<div class="testing"></div>'
141+
});
142+
143+
let data = {
144+
form: {
145+
fname: {
146+
type: 'test'
147+
}
148+
}
149+
};
150+
151+
createForm('<formly-form :form="form" :custom-layout="true"><div id="outside_loop"><formly-field></formly-field></div></formly-form>', data);
152+
153+
expect(vm.$el.querySelectorAll('.testing')).to.be.length(1);
154+
expect(vm.$el.querySelectorAll('fieldset #outside_loop .testing')).to.be.length(1);
155+
156+
});
135157

136158
});

0 commit comments

Comments
 (0)