1
這裏的問題是,如果用戶不填寫的地址重定向用戶通過自動打開的引導模式在CakePHP的控制器故障條件後重定向到模式(自動打開引導模式)
這裏填寫的模態地址是我的控制器這裏代碼
if ($this->request->is('post')) {
['address_line_1']);
if($this->request->data['PropManagementAddress']['address_line_1'] == null){
$this->redirect(array('#myModal'));
//$this->Session->setFlash(__('Add Address by pressing add button below'));
}else {
$this->PropManagementUser->create();
if ($this->PropManagementUser->saveAll($this->request->data)) {
$this->Session->setFlash(__('The user has been saved.'));
return $this->redirect(array('action' => 'index'));
} else {
//prd($this->PropManagementUser->validationErrors);
$this->Session->setFlash(__('The user could not be saved. Please, try again.'));
}
}
是我add.ctp
代碼
<label>Add Address </label>
<button type="button" class="form-group" style="margin-left:140px;"data-toggle="modal" data-target="#myModal">Add</button>
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">addrress</h4>
</div>
<div class="modal-body">
<?php
echo $this->Form->input('PropManagementAddress.address_line_1',array('div' => array('class'=>'form-group'),'placeholder' => 'address line 1','label' => 'Address Line 1','class' => 'form-control'));
echo $this->Form->input('PropManagementAddress.address_line_2',array('div' => array('class'=>'form-group'),'placeholder' => 'address line 2','label' => 'Address Line 2','class' => 'form-control'));
echo $this->Form->input('PropManagementAddress.city_id',array('div' => array('class'=>'form-group'),'type'=>'select','options'=>$cities,'placeholder' =>'city id','label' => 'City ID','class' => 'form-control'));
echo $this->Form->input('PropManagementAddress.state_id',array('div' => array('class'=>'form-group'),'type'=>'select','options'=>$states,'label' => 'State ID','class' => 'form-control'));
echo $this->Form->input('PropManagementAddress.country_id',array('div' => array('class'=>'form-group'),'placeholder' =>'country id','label' => 'Country ID','class' => 'form-control'));
echo $this->Form->input('PropManagementAddress.pincode',array('div' => array('class'=>'form-group'),'type'=>'text','placeholder' => 'pincode','label' => 'Pincode','class' => 'form-control'));
echo $this->Form->input('PropManagementAddress.longitude',array('div' => array('class'=>'form-group'),'type'=>'text','placeholder' => 'longitude','label' => 'Longitude','class' => 'form-control'));
echo $this->Form->input('PropManagementAddress.latitude',array('div' => array('class'=>'form-group'),'type'=>'text','placeholder' => 'latitude','label' => 'Latitude','class' => 'form-control'));
?>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Save</button>
</div>
</div>
</div>
</div>
我試過的是這裏[只是看看這個鏈接](http://stackoverflow.com/questions/6323649/cakephp-can-i-redirect-to-a-specific-div-of-a-view -after-成功) – Fronto