Skip to content

{ hash: true, empty: true } yields empty values for name[] (no index) #40

@nhunzaker

Description

@nhunzaker

I'm working on an app with the following inputs:

<input type="checkbox" name="types[]" value="activities" checked />
<input type="checkbox" name="types[]" value="games" />
<input type="checkbox" name="types[]" value="apps" />
<input type="checkbox" name="types[]" value="videos" checked />

I'm using { hash: true, empty: true } so that I can serialize down an empty types field. However the inputs that aren't checked are showing up in the serialized parameters like:

{
    "types": ["", "activities", "", "videos" ]
}

I would like:

{
    "types": ["activities", "videos" ]
}

and the following when no inputs are checked:

{
    "types": []
}

What do you think about stripping out unchecked boxes if the name field includes no index?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions