0
cakephp 1.2를 사용하여 확인란을 데이터베이스에 문자열로 저장하려고합니다. 컨트롤러 여기cakephp 1.2 여러 확인란 저장
function beforeSave() {
if(($this->data->request['IrIncident']['body_part'])!=='') {
$this->data['IrIncident']['body_part'] = implode('|', $this->data['IrIncident']['body_part']);
$this->data['IrIncident']['rep_date'] = date('Y-m-d');
print_r($this->data);
}
}
됩니다 :
다음<?php echo $form->input('body_part',
array('label' => false,
'type' => 'select',
'multiple' => 'checkbox',
'options' => $bodyparts,
'name' => 'body_part',
'div' => false,
));
?>
모델입니다 : 내가 문자열로 체크 박스를 저장하고 비록 그러나, 여기 .. 저장되지 않는 것은이다
Array ([IrIncident] => Array ([incident_type] => 4 [rep_date] => 2013-05-01 [date] => 2013-05-01 [emp_id] => 1 [department] => 8 [shift] => 10 [location] => Office Space [position] => 15 [injury_type] => 30 [nature_of_injury] => 39 [body_part] => eye, left|eye, right [description] => test [corrective_actions] => test [immediate_cause] => test [basic_root_cause] => test [mod_duty] => Y [mod_days] => 10 [est_cost] => 500 [cause_of_injury] => 56 [responsibility] => You [lost_shifts] => 10 [target_date] => 2013-05-01 [comp_date] =>))
: 여기
function add($member_id = '') {
//var_dump($this->data);
//*Security* make sure user is logged in to access the add method
if ($this -> IrIncident -> loginCheck() == false) {
$this -> Session -> setFlash(__('Please login.', true));
$this -> redirect(array('action' => 'home', 'controller' => 'pages'));
exit();
}
$this->log($this->data);
if ($_SESSION['Incident']['employee'] != '') {
$memberid = $_SESSION['Incident']['employee'];
} else {
$this -> Session -> write('Incident.employee', $member_id);
}
if (!empty($this -> data)) {
$this -> IrIncident -> create();
if ($this -> IrIncident -> save($this -> data)) {
$this -> Session -> setFlash('Incident has been added.');
$this -> redirect(array('action' => 'index'));
}
}
//$this -> set('empref', $this -> IrIncident -> IrEmployee -> find('list', array('conditions' => array('emp_id' => $memberid))));
$empref = $this -> IrIncident -> IrEmployee -> find('list', array('fields' => array('id'), 'conditions' => array('IrEmployee.employee_number' => $memberid)));
$incDept = $this -> IrIncident -> IrGlobaldata -> find('list', array('fields' => array('dvalue1'), 'conditions' => array('IrGlobaldata.dtype' => 'Department'), 'order' => 'dvalue1 ASC'));
$incShift = $this -> IrIncident -> IrGlobaldata -> find('list', array('fields' => array('dvalue1'), 'conditions' => array('IrGlobaldata.dtype' => 'Shift')));
$incPosition = $this -> IrIncident -> IrGlobaldata -> find('list', array('fields' => array('dvalue1'), 'conditions' => array('IrGlobaldata.dtype' => 'Position'), 'order' => 'dvalue1 ASC'));
$incInjType = $this -> IrIncident -> IrGlobaldata -> find('list', array('fields' => array('dvalue1'), 'conditions' => array('IrGlobaldata.dtype' => 'Injury Type'), 'order' => 'dvalue1 ASC'));
$incNature = $this -> IrIncident -> IrGlobaldata -> find('list', array('fields' => array('dvalue1'), 'conditions' => array('IrGlobaldata.dtype' => 'Nature of Injury Damage'), 'order' => 'dvalue1 ASC'));
$incCause = $this -> IrIncident -> IrGlobaldata -> find('list', array('fields' => array('dvalue1'), 'conditions' => array('IrGlobaldata.dtype' => 'Cause of Injury'), 'order' => 'dvalue1 ASC'));
$incType = $this -> IrIncident -> IrGlobaldata -> find('list', array('fields' => array('dvalue1'), 'conditions' => array('IrGlobaldata.dtype' => 'Incident Type'), 'order' => 'dvalue1 ASC'));
$this -> set(compact('empref', 'incDept', 'incShift', 'incPosition', 'incInjType', 'incNature', 'incCause', 'incType'));
}
은 결과 데이터이고
그래서 그게 내가 가지고있는 모든 필드 (comp_date는 DB 또는 cakePHP 유효성 검사에 필요하지 않음)를 제외하고는 여전히 저장되지 않습니다. 문제는 확인란입니다. 이유를 모르겠다.