newforms icon indicating copy to clipboard operation
newforms copied to clipboard

Warning: Each child in an array or iterator should have a unique "key" prop.

Open codyhatch opened this issue 10 years ago • 4 comments

Seems to be an issue with using checkboxes.

let Search = forms.Form.extend({
    customer: forms.CharField({required: false}),
    location: forms.CharField({required: false}),
    payment_method: forms.MultipleChoiceField({
        widget: forms.CheckboxSelectMultiple(),
        choices: [['offline', 'Offline'], ['online', 'Online']],
        required: false
    })
});

class SearchForm extends React.Component {
    searchSubmit(e) {
        e.preventDefault();
        debugger;
    }

    render() {
        return (
            <div>
                <h2>Search Filter</h2>
                <form ref="formWrapper" onSubmit={this.searchSubmit} >
                    <forms.RenderForm form={Search} ref="form">
                        <Container>
                            <Row>
                                <Field name="customer" label="Customer name" md="3" />
                                <Field name="location" label="Store ID / Store name" md="3" />
                                <Field name="payment_method" label="Payment method" md="3" />
                            </Row>
                        </Container>
                    </forms.RenderForm>
                    <button ref="submit" type="submit" >Filter Results</button>
                </form>
            </div>
        );
    }
}

If I change to using the default SelectMultiple widget, the warning goes away.

codyhatch avatar Jun 29 '15 04:06 codyhatch

Warning also appears if you use a RadioSelect()

Sirlon avatar Jul 07 '15 07:07 Sirlon

@insin Is there a roadmap to fix?

vinceprofeta avatar Oct 22 '15 16:10 vinceprofeta

@insin +1, wonderful library, a pain to learn, but worth it in the end if this bug is gone... React requires a unique key property for all fields in a form.

Removed-5an avatar Nov 07 '15 23:11 Removed-5an

Warning also appears with simple Form, such as: var LoginForm = Forms.Form.extend({ coban: Forms.IntegerField(), operador: Forms.IntegerField(), password: Forms.CharField({widget: Forms.PasswordInput}) });

newforms 0.13.2

ivensrocha avatar Jan 07 '16 12:01 ivensrocha