Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Form values drop to initial when show/hide components #115

Open
IgorUsoltsev opened this issue May 30, 2017 · 0 comments
Open

Form values drop to initial when show/hide components #115

IgorUsoltsev opened this issue May 30, 2017 · 0 comments

Comments

@IgorUsoltsev
Copy link

Hi there!

Thanks for the amazing plugin. But I have the following issue.

In my code I have a form in a toggled block - it is shown/hidden by a button click.

So, my form block is shown this way:

var { showFilters } = this.state;
return (
...
<Form
    ref='filterForm'
    onFocus={this.handleFormFocus.bind(this)}
    onChange={this.handleFormChange.bind(this)}
    label="Filters"
>
    {showFilters &&
        tables_filters
    }...

It is rendering just fine, but when I hide this block and show it once again, my form elements values are dropped to initial values.

formData from state is OK, values are saved here. If I submit my form, data is passed. But if a user wants to re-adjust filters in my form, previously applies filters are gone. Clear form.

Components are generated this way:

for (var filter in filters) {
    if (filters[filter]['type'] == 'select') {
        var values = {};
        for (var i in filters[filter]['data']) {
            var val = filters[filter]['data'][i]['val'];            
            var name = filters[filter]['data'][i]['name'];
            values['"' + val + '"'] = name;
        }
        formData[filters[filter]['name']] = { 'val': "", 'type': filters[filter]['type'] };
        formDataOrig[filters[filter]['name']] = { 'val': "", 'type': filters[filter]['type'] };
        tables_filters.push(
            <PickerField
                key={filters[filter]['name']}
                ref={filters[filter]['name']}
                label={filters[filter]['title']}
                options={
                    values
                }
                value={formData[filters[filter]['name']].val}
                containerStyle={
                    { alignItems: 'center', justifyContent: 'space-between' }
                }
                iconRight={
                    [<Icon
                        key={filters[filter]['name'] + 'icon'}
                        style={{ alignSelf: 'center', marginLeft: 10, marginRight: 10, marginTop: 4 }}
                        name='ios-arrow-down' size={20} />
                ]}
            />
        );
    }...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant