forms icon indicating copy to clipboard operation
forms copied to clipboard

simple checkbox

Open leejoramo-d51 opened this issue 6 years ago • 1 comments

I am trying to get a simple single checkbox to work. I can't get the value to work. The two closest approaches are have found are array/multipleCheckbox and string/checkbox. However, neither is quite what I want. Here is the javascript:

    blue: fields.array({
        choices: { one: 'item 1' },
        widget: widgets.multipleCheckbox()
    }),
    green: fields.string({
        value: 'abc',
        widget: widgets.checkbox()
    }),

and the resulting HTML:

<div class="field">
    <fieldset>
        <legend>Blue</legend>
        <input type="checkbox" name="blue" id="id_blue_one" value="one" />
        <label for="id_blue_one">
            item 1
        </label>
    </fieldset>
</div>
<div class="field">
    <label for="id_green">Green</label>
    <input type="checkbox" name="green" id="id_green" value="on" />
</div>

Using the array/multipleCheckbox I actually get the <input> code I want. It has the correctly set value, but it is wrapped in an unwanted <fieldset>.

The other version using string/checkbox doesn't have the <fieldset> but the value incorrectly set to "on".

leejoramo-d51 avatar Sep 14 '18 22:09 leejoramo-d51

Why don't you want the fieldset there?

ljharb avatar Sep 21 '21 18:09 ljharb