即時通訊嘗試創建一個視圖,其中用戶選擇了他們創建的模板編號然後被帶到下一個頁面,在那裏它分配出他們爲該模板創建的字段。我有我的SQL語句做什麼,我希望他們這樣做,但我是如何得到的形式,這些custom
領域default_values
打印輸出到輸入框cakephp創建一個用戶輸入的形式
發票表包含不確定id sender_id receiver_id template_id
領域表包含id name default_value active template_id
invoices hambt fields
fields hambt invoices
有連接表fields_invoices,它包含id invoice_id field_id entered value
我不確定如何獲取的ID從發票表和字段的表保存到連接表
public function create($id)
{
$this->set('title_for_layout', 'Create Invoice');
$this->set('stylesheet_used', 'homestyle');
$this->set('image_used', 'eBOXLogoHome.png');
$this->layout='home_layout';
if (!is_numeric($id)) throw new BadMethodCallException('I need an ID');
$this->Invoice->id = $id;
if (!$this->Invoice->exists()) throw new NotFoundException('Invalid ID');
$this->set('invoice_id',$id);
$names = $this->Invoice->find('list',array(
'fields'=>array('template_id'),
'conditions'=>array('id'=>$id)));
$fields = $this->Field->find('list', array(
'conditions'=>array(
'template_id'=>$names)));
$this->set('field',$fields);
$this->set('name',$names);
if(empty($this->data)){
$this->data= $this->Field->read($fields);
}
else{
if(($this->Field->save($this->data)))
{
$this->Session->setFlash('The field has been updated');
$this->redirect(array('controller'=>'invoices', 'action'=>'index'));
}
}
}
這裏是視圖
<?php echo $this->Form->create('fields_invoices'); ?>
<?php foreach ($field as $fields): ?>
<?php echo $this->Form->Input($fields); ?>
<?php endforeach ;?>
<?php echo $this->Form->End('Submit');?>
現在我對如何看法正確的代碼,並得到它,使它在fields
表打印出default_variables
到input boxes
不確定。任何幫助將不勝感激