我正在尝试构建模态框以在模态弹出式bootrap中显示Session-> setFlush()方法的结果,我已经完成但无法找到在模式对话框中显示flash消息的方法注册完成后。 这是我的函数控制器代码:
public function inscriptioncompte(){
$this->Session->setFlash("Verifier votre boite mail afin de valider votre inscription.",'ok');
if ($this->request->is(array('post', 'put'))) {
$posted_data = $this->request->data;
$interet = rtrim($interet, ";");
$this->User->create();
$this->User->set(array(
'username'=>$posted_data['User']['username'],
'password'=>$posted_data['User']['password'],
'group_id'=>3));
$datenaissance = date("Y-m-d",strtotime($posted_data['User']['datenaissance']));
if($this->User->validates()){
if($this->User->save()){
$this->Session->setFlash("Verifier votre boite mail afin de valider votre inscription.",'ok');
$this->redirect( Router::url( $this->referer(), true ) );
}else{
$this->Session->setFlash("Une erreur c'est produite lors de votre inscription.",'ko');
$this->redirect( Router::url( $this->referer(), true ) );
}
}else{
$erreurs = $this->User->invalidFields();
$erreurToShow = "";
if(isset($erreurs['username']['0']) && !empty($erreurs['username']['0'])){
$erreurToShow = $erreurs['username']['0'];
}
if(isset($erreurs['password']['0']) && !empty($erreurs['password']['0'])){
$erreurToShow = $erreurToShow.$erreurs['password']['0'];
}
$this->Session->setFlash("Erreur : ".$erreurToShow,'ko');
$this->redirect( Router::url( $this->referer(), true ) );
}
}
}
这是模态代码:
<div id="printPlaning" class="modal fade" role="dialog" aria-labelledby="gridSystemModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="gridSystemModalLabel">Imprimez votre planing</h4>
</div>
<div class="modal-body">
<label for="formation_id"> text body</label>
<div>
input
</div>
</div>
<div class="modal-footer">
footer
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
任何想法,我该怎么做?
答案 0 :(得分:1)
我使用这样的JQuery解决了这个问题:
$(document).ready(function(){
var ins = <?php echo $inscription; ?>;
if(ins){
$('#printPlaning').modal('show');
}
});
当我打电话给我的控制器时,$题词virable正在进行