I have created two database tables:
sellers_tbls
id
business_name
businesstype_tbls_business_type
mobile
businesstype_tbls
id
business_type
where businesstype_tbls
is for displying dropdown types upon registration.
After submitting the form, register()
is saving businesstype_tbls.id
in sellers_tbls.businesstype_tbls_business_type
.
How can I get business_type
instead of id
in my sellers_tbls
?
My code is as follows:
register.ctp
<tr>
<td>Business type</td>
<td><?php echo $this->Form->select('businesstype_tbls_business_type',$drop);?></td>
</tr>
SellerController
public function register()
{
$this->loadModel("Seller");
if($this->Seller->save($this->request->data))
{
$this->Session->setFlash('Successully save your information!');
}
$this->loadModel("Businesstype");
$dt=$this->Businesstype->find('list',array('fields'=>array('id','business_type')));
$this->set('drop',$dt);
}
Model Businesstype.php
class Businesstype extends AppModel
{
public $name = 'businesstype_tbls';
public $hashMany = 'sellers_tbls';
}
Model Seller.php
class Seller extends AppModel
{
public $name = 'sellers_tbls';
public $belongsTo = 'businesstype_tbls';
}