<commit_before>import React, {Component, PropTypes} from 'react';
import {connect as connectToForm } from '../../behaviours/form';
import {connect as connectToMetadata} from '../../behaviours/metadata';
import {connect as connectToFieldHelpers} from '../../behaviours/field';
import {connect as connectToMasterData} from '../../behaviours/master-data';
import {loadMixedAction, saveMixedAction} from '../actions/mixed-actions';

import Panel from '../../components/panel';
import compose from 'lodash/flowRight';

class UserAddressForm extends Component {
    componentWillMount() {
        const {id, load, loadMasterData} = this.props;
        load({id});
        loadMasterData();
    }

    render() {
        const {editing, fields, fieldFor, list, selectFor} = this.props;
        return (
            <Panel title='User and address' {...this.props}>
                {fieldFor('uuid', {onChange: () => {console.log(fields)}, entityPath: 'user'})}
                {list('childs', {entityPath : 'user', redirectEntityPath: 'child'})}
            </Panel>
        );
    }
};

UserAddressForm.displayName = 'UserAddressForm';

const formConfig = {
    //todo: it should raise an error if i use the same formKey.
    formKey: 'userAndAddressForm',
    entityPathArray: ['user', 'address'/*, 'child'*/],
    loadAction: loadMixedAction,
    saveAction: saveMixedAction,
    nonValidatedFields: ['user.uuid', {'user.childs': ['firstName']}    ]
};

//Connect the component to all its behaviours (respect the order for store, store -> props, helper)
const ConnectedUserAddressForm = compose(
    connectToMetadata(['user', 'address', 'child']),
    connectToMasterData(['civility']),
    connectToForm(formConfig),
    connectToFieldHelpers()
)(UserAddressForm);

export default ConnectedUserAddressForm;<commit_msg>[example] Update it with new fieldFor<commit_after>import React, {Component, PropTypes} from 'react';
import {connect as connectToForm } from '../../behaviours/form';
import {connect as connectToMetadata} from '../../behaviours/metadata';
import {connect as connectToFieldHelpers} from '../../behaviours/field';
import {connect as connectToMasterData} from '../../behaviours/master-data';
import {loadMixedAction, saveMixedAction} from '../actions/mixed-actions';

import Panel from '../../components/panel';
import compose from 'lodash/flowRight';
import LineComponent from '../../components/line'
class UserAddressForm extends Component {
    componentWillMount() {
        const {id, load, loadMasterData} = this.props;
        load({id});
        loadMasterData();
    }

    render() {
        const {editing, fields, fieldFor, listFor, selectFor} = this.props;
        return (
            <Panel title='User and address' {...this.props}>
                {fieldFor('uuid', {onChange: () => {console.log(fields)}, entityPath: 'user'})}
                {listFor('childs', {LineComponent, entityPath : 'user', redirectEntityPath: 'child'})}
            </Panel>
        );
    }
};

UserAddressForm.displayName = 'UserAddressForm';

const formConfig = {
    //todo: it should raise an error if i use the same formKey.
    formKey: 'userAndAddressForm',
    entityPathArray: ['user', 'address'/*, 'child'*/],
    loadAction: loadMixedAction,
    saveAction: saveMixedAction,
    nonValidatedFields: ['user.uuid', {'user.childs': ['firstName']}    ]
};

//Connect the component to all its behaviours (respect the order for store, store -> props, helper)
const ConnectedUserAddressForm = compose(
    connectToMetadata(['user', 'address', 'child']),
    connectToMasterData(['civility']),
    connectToForm(formConfig),
    connectToFieldHelpers()
)(UserAddressForm);

export default ConnectedUserAddressForm;
{'fraction_non_alphanumeric': 0.1476906552094522, 'fraction_numerical': 0.0, 'mean_word_length': 3.6855345911949686, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5317775', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1047, 'n_words': 285}