associations - Where should I add data for an associated model in cakephp-3 -


i create few default entities users when register account, example being profile, there no data user registration form, user entities should have profile still seems fitting create it.

before 'but there no data, cope in controller/views' - yes know, not use cases allow it, , require empty/default data.

is should added data register form in controller, before doing save? me seems more logical there should in model says valid user has profile, , if there no data there create (perhaps using username profile full name).

  1. is achievable in beforesave callback or controller?

  2. is there minimum need have in patchentity related entity save (my current attempts have profile in debug, none of data thought setting, nothing saves)

many thanks

i hope got questions right.

  1. yes why shouldn't possible? create associated(http://book.cakephp.org/3.0/en/orm/saving-data.html#saving-with-associations) entry , make fields nullable.

  2. to save related should follow convention user(id,name,pw,...) profile(id,user_id,...) make sure user has 1 profile make user_id unique.


Comments

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -