Allow duration field to specify labels of sub-fields
This commit is contained in:
parent
4a99a5acf5
commit
4d9dae5e3b
@ -65,11 +65,11 @@
|
||||
hint="This is a hint" validation={{message: 'This is a validation error'}}/>
|
||||
<Field type="password" name="password" placeholder="Password field" icon="key"
|
||||
hint="This is a hint" validation={{message: 'This is a validation error'}}/>
|
||||
<Field type="duration" name="duration" placeholder="Duration field" icon="clock" extraData={[
|
||||
'h',
|
||||
'm',
|
||||
's',
|
||||
]} hint="This is a hint" validation={{message: 'This is a validation error'}}/>
|
||||
<Field type="duration" name="duration" placeholder="Duration field" icon="clock" extraData={{
|
||||
h: 'Hours',
|
||||
m: 'Minutes',
|
||||
s: 'Seconds',
|
||||
}} hint="This is a hint" validation={{message: 'This is a validation error'}}/>
|
||||
<Field type="select" name="select" placeholder="Select field" icon="list" extraData={[
|
||||
'Option 1',
|
||||
'Option 2',
|
||||
|
@ -387,13 +387,13 @@
|
||||
{#if type === 'duration'}
|
||||
<fieldset>
|
||||
<legend>{placeholder}</legend>
|
||||
{#each extraData as f}
|
||||
{#each Object.keys(extraData) as f}
|
||||
<div class="time-input">
|
||||
<input type="number" name="{name}[{f}]" id="{fieldId}-{f}"
|
||||
value={durationValue(f)}
|
||||
min="0" max={(f === 's' || f === 'm') && '60' || undefined}
|
||||
{...$$restProps} on:click={e => e.stopPropagation()}>
|
||||
<label for="{fieldId}-{f}" on:click={e => e.stopPropagation()}>{f}</label>
|
||||
<label for="{fieldId}-{f}" on:click={e => e.stopPropagation()}>{extraData[f] || f}</label>
|
||||
</div>
|
||||
{/each}
|
||||
</fieldset>
|
||||
|
Loading…
Reference in New Issue
Block a user