|
@@ -39,6 +39,13 @@ const EditFormRow = ({field, models={}, value, options=defaultAdminOptions, reco
|
|
|
const EditForm = ({record, models={}, model, options=defaultAdminOptions, Components:{EditFormRow:EFR}={EditFormRow}}) => {
|
|
|
const [edit, setEdit] = useState({...record})
|
|
|
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (record && record.empty){
|
|
|
+ record.then(() => setEdit({...record}))
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
if (!record) return <></>
|
|
|
|
|
|
if (!record.save || !record._id){
|
|
@@ -74,9 +81,7 @@ const EditForm = ({record, models={}, model, options=defaultAdminOptions, Compon
|
|
|
<button onClick={async () => {
|
|
|
await record;
|
|
|
Object.assign(record, edit);
|
|
|
- if ('_id' in record && 'save' in record){
|
|
|
- record.save()
|
|
|
- }
|
|
|
+ record.save()
|
|
|
}}>
|
|
|
Save
|
|
|
</button>}
|