0
votes

I am creating my form in the layout of my application and the view just have inputs.

// In layout
$this->Form->create('modelname');

// In view
$this->Form->input('fieldname');

Is there a way I can set default Model in my view just like inputDefaults

$this->Form->inputDefaults(array(
     'label' => false,
    'div' => false,
    'class' => 'fancy'
)
); 

Cake Validation only works if it found input using [modelname][fieldname], so I can write in the view

 $this->Form->input('modelname.fieldname');

but I have to change all of my forms.

Is there any way I can set model name in the view??

1

1 Answers

0
votes

Why the .... are you creating your form in the layout?? This is very wrong unless there is some great reason for it (and I cannot see no such reason):

// In layout
$this->Form->create('modelname');
// In view
$this->Form->input('fieldname'); 

You should create separate forms in each view there is a form. Since each form is tied to a different model. Your validation is not working without modelname.fieldname since every form in every view does not attach itself to the right Model... You should creare every form in every view with:

$this->Form->create('specficmodelname');