【问题标题】:Displaying flash messages on modal popup cakephp在模式弹出 cakephp 上显示 flash 消息
【发布时间】:2017-04-09 07:18:35
【问题描述】:

我正在尝试构建模态框以在模态弹出引导程序中显示 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">&times;</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 twitter-bootstrap flash cakephp modal-dialog


    【解决方案1】:

    我通过使用这样的 JQuery 解决了这个问题:

    $(document).ready(function(){
           var ins = <?php echo $inscription; ?>;
           if(ins){
            $('#printPlaning').modal('show');
           }
    
     });
    

    当我调用我的控制器时,$inscription 病毒正在到来

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-29
      • 1970-01-01
      • 1970-01-01
      • 2010-11-06
      • 2018-06-25
      相关资源
      最近更新 更多