在模态弹出窗口 cakephp 上显示 flash 消息
Displaying flash messages on modal popup cakephp
我正在尝试构建模态框以在模态弹出引导程序中显示 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 -->
请问我该怎么做?
我通过这样使用 JQuery 解决了这个问题:
$(document).ready(function(){
var ins = <?php echo $inscription; ?>;
if(ins){
$('#printPlaning').modal('show');
}
});
当我调用我的控制器时,$inscription 变量就来了
我正在尝试构建模态框以在模态弹出引导程序中显示 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 -->
请问我该怎么做?
我通过这样使用 JQuery 解决了这个问题:
$(document).ready(function(){
var ins = <?php echo $inscription; ?>;
if(ins){
$('#printPlaning').modal('show');
}
});
当我调用我的控制器时,$inscription 变量就来了