Browse Source

annoying save fix

Ivan Asmer 4 years ago
parent
commit
75969cf7bb
1 changed files with 6 additions and 1 deletions
  1. 6 1
      src/App.js

+ 6 - 1
src/App.js

@@ -28,6 +28,10 @@ const EditForm = ({record, models={}, model, options=defaultAdminOptions, Compon
 
     if (!record) return <></>
 
+    if (!record.save || !record._id){
+        Object.assign(record, edit)
+    }
+
     const fields =  model.fields
     const onlyInputs = model.inputs.filter(input => !fields.find(field => field.name === input.name))
     return (
@@ -53,13 +57,14 @@ const EditForm = ({record, models={}, model, options=defaultAdminOptions, Compon
 
                 </tbody>
             </table>
+            {record._id && record.save && 
             <button onClick={() => {
                 Object.assign(record, edit);
                 if ('_id' in record && 'save' in record)
                     record.save()
             }}>
                 Save
-            </button>
+            </button>}
         </>
     )
 }