1
我有表格,其中的選擇框在那裏,並選擇所有選項,我想發佈所有數據沒有點擊複選框,我不想查看此頁面,意思是如果用戶轉到註冊頁面數據將已經選擇默認我怎麼做,沒有任何觀點? 這是我的看法代碼如何發佈數據與點擊複選框cakephp?
<?php v_start($this);?>
<?php
#if(element exits of controller-action)
echo $this->element('validations/users/signup');
?>
<script>
function toggleChecked(status)
{
jQuery(".new-checkbox input").each(function() {
jQuery(this).attr("checked",status);
}
)
}
</script>
<h1><span style="color:CornflowerBlue"><?php echo __l('Step1');?></span></h1>
<?php
$form = $this->FormManager;
echo $form->create('User',array_merge($form_options,array('default'=>true)));
?>
<table width = "100%">
<tbody>
<tr>
<td>
<?php echo $form->input('',array('id'=>'mark-all','onclick'=>'toggleChecked(this.checked)','type'=>'checkbox','label'=>'Select All Products'));?>
<?php echo $form->input('product_id',
array(
'multiple'=>'checkbox',
'options'=>$products,
'div'=>false,
'class'=>'new-checkbox'
)
);
?>
</td>
</tr>
<tr>
<td>
<?php
echo $this->FormManager->end(LBL_BTN_NEXT);
?>
</td>
</tr>
</tbody>
</table>
我不希望這個頁面,用戶將默認選擇的數據。 這是我的控制器代碼
$products = $this
->User
->ProductsUser
->Product
->find('list',array(
'fields' => 'product_id,name',
'conditions'=>array(
'Product.is_visible'=>true
)
)
);
$this->set('products',$products);
if($this->request->is('post'))
{
$this->Session->write('signUp.signUpProduct',$this->request->data['User']);
$this->redirect(array('action'=>'signup_product'));
}
}
我怎麼能做到這一點,在此先感謝。
你的英語很難理解。你提到選擇框,但你的代碼呈現複選框,而不是選擇框。另外,你提到你想要發佈用戶默認選擇的數據,但是你希望在沒有表單的情況下這樣做。如果沒有表單,用戶如何選擇要發佈的數據?數據是通過Javascript進入的嗎?我相信我可以幫助你。請稍微澄清一下你的問題。 – 2013-03-25 22:15:51