Here Countrymaster is related to Customermaster as Customermaster belongs to Countrymaster, then Customermaster related to User as User has many Customermaster
To access the customermaster relation in user register form
Controller
$this->set('countrymasters', $this->User->Customermaster->Countrymaster->find('list'));
View file:
<?php echo $this->Form->input('email',array('label' => '')); ?> // this field is from user table
<?php echo $this->Form->input('Customermaster.dob',array('label' => '')); ?> // this field is from customermaster table
<?php echo $this->Form->input('Countrymaster',array('label' => '')); ?> // this field is from countrymster table related to customermaster
Refer
http://book.cakephp.org/1.3/en/The-Manual/Core-Helpers/Form.html
To access the customermaster relation in user register form
Controller
$this->set('countrymasters', $this->User->Customermaster->Countrymaster->find('list'));
View file:
<?php echo $this->Form->input('email',array('label' => '')); ?> // this field is from user table
<?php echo $this->Form->input('Customermaster.dob',array('label' => '')); ?> // this field is from customermaster table
<?php echo $this->Form->input('Countrymaster',array('label' => '')); ?> // this field is from countrymster table related to customermaster
Refer
Here’s an example for creating a hasAndBelongsToMany select. Assume that User hasAndBelongsToMany Group. In your controller, set a camelCase plural variable (group -> groups in this case, or ExtraFunkyModel -> extraFunkyModels) with the select options. In the controller action you would put the following:
$this->set('groups', $this->User->Group->find('list'));
And in the view a multiple select can be expected with this simple code:
echo $this->Form->input('Group');
If you want to create a select field while using a belongsTo- or hasOne-Relation, you can add the following to your Users-controller (assuming your User belongsTo Group):
$this->set('groups', $this->User->Group->find('list'));
Afterwards, add the following to your form-view:
echo $this->Form->input('group_id');
http://book.cakephp.org/1.3/en/The-Manual/Core-Helpers/Form.html
0 comments:
Post a Comment