'; // echo $this->Form->input('User.' $row '.email',array('type'=>'text')); echo $this->Form->input('User.'.$row.'.email',array('type'=>'text')); echo ' | '; echo ''; echo $this->Form->input('User.'.$row.'.username',array('type'=>'text')); echo ' | '; echo ''; echo $this->Form->button('行削除',array('type'=>'submit', 'name'=>$count)); echo ' | '; echo '
Form->hidden('Table.count', array('value' => $count )); echo $this->Form->button('行追加', array('type'=>'submit','name'=>'buttonType','value'=>'addRow') ); ?> |
2016年10月30日日曜日
CakePHP2 行追加
Form->create('User', array('novalidate' => true));
?>
request->data); ?>
request->data['User'])){
foreach ($this->request->data['User'] as $key => $value) {
// debug($key);
$count+=1 ;
$row=$count -1;
debug($count);
echo '
Form->end();
?>
//cotroller
private function __addRow(){
//Hiddenにセットしておく
if(isset($this->request->data['Table']['count'])){
$count = $this->request->data['Table']['count'];
for($i=0; $i<$count+1 ; $i++){
$this->request->data['User'][$i]['email']=
(isset($this->request->data['User'][$i]['email']))? $this->request->data['User'][$i]['email'] : '';
$this->request->data['User'][$i]['username']=
(isset($this->request->data['User'][$i]['username']))? $this->request->data['User'][$i]['username'] : '';
}
}
}
public function test(){
$this->__addRow();
}
登録:
コメントの投稿 (Atom)
0 件のコメント:
コメントを投稿