Skip to content

Checklist inputName generation #461

Open
@mix359

Description

@mix359

Hi,

I'm trying to use the checklist in a form that will be submitted using standard html form request, and I'm facing a problem with the name generated for the checkbox inside the checklist.

With a normal html form you can send the values of some fields as array, setting their names to field[] or field[name]. That request is interpreted by PHP (I don't know the other languages) as an array of values, so it's easy to save the values of something like a multi-checkbox.
There's two types of array you can generate:

<input type="checkbox" name="columns[]" value="test1" /> <input type="checkbox" name="columns[]" value="test2" />

That would generate (if all the checkbox is checked) an array with ["test1", "test2"];

<input type="checkbox" name="columns[test1]" value="1" /> <input type="checkbox" name="columns[test2]" value="1" />

That would generate (if all the checkbox is checked) an array with ["test1" => 1, "test2" => 1];

I would like to use the first behavior to save some columns if their checked, but with the current way of generate the checkbox fieldName I can't. It currently generated as fieldName_checkboxName, and there require a processation in the backend to know which checkbox are selected.

I would ask if there's currently any option to obtain that fieldName/value combination, or if not, if I can send a PR that add the ability to use a lambda as inputName or option in checklistOptions, to generate the name of the internal checkbox.

Thanks
Cheers
Mix

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions