이것은 조치 URL : http://localhost/carsdirectory/users/dashboard
입니다.삽입 검색어가 케이크 PHP에서 작동하지 않습니다
dashboad.ctp
<?php echo $this->Form->create('User', array('type' => 'file', 'action' => 'dashboard')); ?>
<label class="ls-details-label">Type</label>
<div class="ls-details-box">
<?php
foreach ($car_types as $car_type)
{
$car_type_new[$car_type['Car_type']['id']]=
$car_type['Car_type']['car_type'];
}
echo $this->Form->input('car_type',
array( 'label'=>false,
'options'=>$car_type_new,
'empty'=>' Select ',
'class'=>'styledselect_form_1'));
?>
</div>
<?php echo $this->Form->end(array('label' => 'Submit',
'name' => 'Submit',
'div' => array('class' => 'ls-submit')));?>
users_controller.php (컨트롤러)
class UsersController extends AppController{
var $name = "Users";
public function dashboard(){
$this->loadModel('Car_type'); // your Model name => Car_type
$this->set('car_types', $this->Car_type->find('all'));
if(!empty($this->data))
{
$this->loadModel('Car');
if($this->Car->save($this->data))
{
$this->Session->setFlash('Detail has Been Saved');
$this->redirect(array('action'=>'dashboard'));
}
else
{
$this->Session->setFlash('Detail could not save');
}
}
}
차 (I 그 출원 car_type 테이블 이름 car_types 데이터를 페치 출원이 선택 필드 IM에서 선택한 한) .php (모델)
<?php
class Car extends appModel{
var $name = "Car";
}
?>
데이터를 삽입하려는 car_type_id 필드 (table
그래서 PLZ, 카스 tyagi
VAR를 사용하지 마십시오. PUBLIC을 사용하십시오. – cwallenpoole
'else'로가는 것이 오류입니까? –
답장을 보내 주셔서 감사합니다. 공개했으나 여전히 car_type_id에 null 값이 기록되었습니다. –