2019-10-16 06:38:45 +02:00
|
|
|
<script>
|
2019-11-23 09:15:28 +01:00
|
|
|
|
2019-10-16 06:38:45 +02:00
|
|
|
export let formControls = [];
|
|
|
|
|
|
|
|
export let _bb;
|
|
|
|
|
|
|
|
let htmlElements = {};
|
|
|
|
let labelElements = {};
|
|
|
|
let labels = {};
|
|
|
|
let isInitialised = false;
|
|
|
|
|
|
|
|
$ : {
|
|
|
|
|
|
|
|
if(_bb && htmlElements && !isInitialised) {
|
|
|
|
|
|
|
|
let cIndex = 0;
|
|
|
|
for(let c of formControls) {
|
|
|
|
labels[cIndex] = c.label;
|
|
|
|
cIndex++;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(let el in htmlElements) {
|
|
|
|
if(formControls[el].control.controlPosition === "Before Label") {
|
2020-01-18 00:06:42 +01:00
|
|
|
_bb.insertChildren(
|
2019-10-19 08:24:20 +02:00
|
|
|
_bb.props.formControls[el].control,
|
2019-10-16 06:38:45 +02:00
|
|
|
htmlElements[el],
|
2019-11-23 09:15:28 +01:00
|
|
|
htmlElements[el].childNodes.find(n => n.tagName === "LABEL"));
|
2019-10-16 06:38:45 +02:00
|
|
|
} else {
|
2020-01-18 00:06:42 +01:00
|
|
|
_bb.appendChildren(
|
2019-10-19 08:24:20 +02:00
|
|
|
_bb.props.formControls[el].control,
|
2019-10-16 06:38:45 +02:00
|
|
|
htmlElements[el]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
isInitialised = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<form>
|
2019-11-23 09:15:28 +01:00
|
|
|
{#each formControls as child, idx}
|
|
|
|
<div class="form-group" bind:this={htmlElements[idx]}>
|
|
|
|
<label>{labels[idx]}</label>
|
2019-10-16 06:38:45 +02:00
|
|
|
</div>
|
|
|
|
{/each}
|
|
|
|
</form>
|
|
|
|
|