cakephp2.x で
フォームのチェックボックスから複数タグを保存したいのですが、
その項目がarrayになって保存あできません。jso_encode を使っているのですが、
やっぱりrequest->data がarrayになってしまいます。
他の部分は保存されています。
どうすれよいか教えていただけたら幸いでございます。
contrller 名前Encode public function find(){ $tag_id = $this->Compornet->originalfind('Tag',$w,$o); $this->set(compact('tag_id')); if($this->data){ if(!empty($this->data["json"])){ $popai = $this->data["json"]; $this->data['Encode']['json'] = json_encode($popai); } if($this->Encode->save($this->data)){ $this->Session->setFlash(__('成功しました!')); } } }
view find.ctp <form action="" method="post"> <?=$this->Form->input('type',array('type' => 'text','label' => '会社職種'));?> <?=$this->Form->input('name',array('type' => 'text','label' => 'タイトル'));?> <?=$this->Form->input('read',array('type' => 'text','label' => 'リード文'));?> <?=$this->Form->input('email',array('type' => 'text','label' => '仕事内容'));?> <?=$this->Form->input('qualification',array('type' => 'text','label' => '応募資格'));?> <?=$this->Form->input('jusho',array('type' => 'text','label' => '会社住所'));?> <?php echo $this->Form->input('img_file_name',array('type' =>'file','label' => 'サムネイルアップ'));?> <?php foreach($tag_id as $k => $v):?> <label><input type="checkbox" name='json[]' value="<?php echo $v['Tag']['id'];?>" <?php if(isset($tag_id) && in_array($v['Tag']['id'],$tag_id)){echo 'checked';}?>> <?php echo $v['Tag']['name'];?> </label> <?php endforeach;?> <?=$this->Form->input('送信',array('type' => 'submit'));?> </form>