validation - Create form for multiple/two NOT related models in CakePHP -


i have 2 models: modela, modelb. booth have id, name, ..., done(bool) fields.

modela not relate way modelb!

i created 1 form, have booth models fields in modela/add.ctp

echo $this->form->create('modela', [ ... ]);  echo $this->form->input('modela.name'); ... echo $this->form->input('modela.done', [     'default' => true ]);   echo $this->form->input('modelb.name'); ... echo $this->form->input('modelb.done', [     'default' => true ]); 

my problem, cake not create checkbox modelb.done instead simple input field. not validates modelb. (because not know these fields relates modelb.)

i can manually validation, loading modelb in modela controller , like: $this->modelb->validate(...)

my question is: possible set form has 2 not related model?

i don't think there's way set 2 unrelated models , validate them without calling validate function.

however, checkbox issue solved.

use this:

   echo $this->form->input('modelb.done', [     'type'    => 'checkbox',     'default' => true    ]); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -