admin on rest - Auto clear data in Edit Page -
i created dialog contains create form inside edit form. when click on "new relationship" button, dialog shown, don't know why records in edit form cleared.
here code:
export class caregiveredit extends react.component { constructor(props) { super(props); this.state = { open: false, }; } handleopen = () => { this.setstate({open: true}); }; handleclose = () => { this.setstate({open: false}); }; render() { const style = { margin: 12, }; const actions = [ <flatbutton label="ok" onclick={ this.handleclose } />, ]; var id = this.props.location.pathname.split('/')[2]; const propscreate = object.assign({}, this.props, { authparams : {resource : "rela", route : "create"}, location : {pathname : "/rela/create"}, match : { path : "/rela/create", url : "/rela/create"}, resource : "rela" }); return ( <div> <edit title={<caregivertitle />} {...this.props}> <simpleform> <disabledinput source="id"/> <imagefield source="profile_photo" /> <textinput source="profile_photo" /> <textinput source="name" /> <textinput source="email" validate={email}/> <textinput source="phone" /> <booleaninput source="status" label="active"/> <cardtitle title="* relationship" titlestyle={{'fontsize':'18px'}}/> <raisedbutton label="new relationship" onclick={this.handleopen} style={style}/> <gridfield uid={id} {...this.props} /> <dialog title="new relationship" actions={actions} modal={false} open={this.state.open} onrequestclose={this.handleclose} autoscrollbodycontent={true}> <div> <br/> <create {...propscreate} title=" " actions=""> <simpleform redirect={"/caregiver/" + id}> {/*<referencearrayinput>*/} <disabledinput source="user" defaultvalue={id} label="caregiver id"/> <referenceinput label="centre" source="centre" reference="centre" sort={{ field: 'name', order: 'asc' }} allowempty> <selectinput optiontext="name" /> </referenceinput> <dependentinput dependson="centre"> <subgenreinput source="current_group" optiontext="label" optionvalue="id" type="classgroup"/> </dependentinput> <dependentinput dependson="current_group"> <subgenreinput source="student_id" optiontext="fullname" optionvalue="id" type="student"/> </dependentinput> {/*</referencearrayinput>*/} <radiobuttongroupinput source="account_type" defaultvalue={10} choices={[ { id: 10, name: 'caregiver' }, { id: 20, name: 'guardian' }, ]} optiontext="name" optionvalue="id" /> <textinput source="relationship" label="relationship"/> </simpleform> </create> </div> </dialog> </simpleform> </edit> </div> ) }
that's because forms in aor have same name: record-form. think after create operation, send reset action form in order support "save , create new" scenario. please open issue can discuss this.
edited after discussion:
the fastest solution have edition view caregiver , 1 relationship. mentioned n-to-n relationship intermediate table. complexity should hidden client. that's job of either api or restclient.
from client point of vue, have 2 entities using referencearrayinput maintain references between them.
if want have edition/creation described before, you'll have implement own react components, using aor restclient fetch/update data.



Comments
Post a Comment