Init work with making field required
This commit is contained in:
@@ -2,12 +2,17 @@
|
||||
export let label;
|
||||
export let value;
|
||||
export let options = [];
|
||||
export let valueKey = "id";
|
||||
export let valueKey = 'id';
|
||||
export let isRequired = false;
|
||||
</script>
|
||||
|
||||
<label class="block">
|
||||
{#if label} <span class="text-gray-700">{label}</span> {/if}
|
||||
<select bind:value class="form-select block w-full mt-1">
|
||||
<select
|
||||
bind:value
|
||||
class="form-select block w-full mt-1"
|
||||
required={isRequired}
|
||||
>
|
||||
{#each options as option}
|
||||
<option value={option[valueKey]}>
|
||||
{option.text}
|
||||
|
||||
@@ -8,11 +8,16 @@
|
||||
export let inputClassName = '';
|
||||
export let type = 'text';
|
||||
export let autoFocus = false;
|
||||
export let isRequired = false;
|
||||
|
||||
let ref = null;
|
||||
let ref;
|
||||
|
||||
function typeAction(node) {
|
||||
node.type = type;
|
||||
|
||||
if (isRequired) {
|
||||
node.required = '';
|
||||
}
|
||||
}
|
||||
|
||||
afterUpdate(() => {
|
||||
@@ -31,5 +36,6 @@
|
||||
{placeholder}
|
||||
bind:value
|
||||
bind:this={ref}
|
||||
required={true}
|
||||
/>
|
||||
</label>
|
||||
|
||||
Reference in New Issue
Block a user