2014-07-03 179 views
0

我有用于创建管理员的模态窗体。来自该模式的所有数据都可以正确保存在数据库中,但问题是当我想要转到另一个链接时出现错误,并显示一些弹出窗口'ajax error!'。Yii渲染模态问题

例如:首先我去://.../administrator然后我点击'create'按钮来显示'create modal',我完成了所有表单,然后点击提交然后我想去// ... /主题,问题在这里,我不能去://.../theme,URL变成这样://.../administrator/theme。其实我想去://.../theme

我不知道该怎么办,请大家帮忙

这里有鉴于模态代码:

<?php 
    $baseURL = Yii::app()->getBaseUrl(true); 
?> 

    <div class="modal fade" id="modal-create"> 
         <div class="modal-dialog"> 
          <div class="modal-content"> 
           <!-- Modal heading --> 
           <div class="modal-header"> 
            <button type="reset" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
            <h3 class="modal-title">Create Administrator</h3> 
           </div> 
           <!-- // Modal heading END --> 

           <!-- Modal body --> 
           <div class="modal-body"> 
            <div class="innerAll"> 
             <div class="innerLR"> 
              <form class="form-horizontal" role="form" action="<?php echo $baseURL; ?>/administrator/create" method="POST"> 
                <div class="widget-body innerAll inner-2x"> 
                 <!-- Row --> 
                 <div class="row innerLR"> 
                   <!-- Group --> 
                   <div class="form-group"> 
                    <label class="col-sm-2 control-label" for="firstname">First name</label> 
                    <div class="col-sm-8"> 
                     <input class="form-control" id="fname" name="fname" type="text"/> 
                    </div> 
                   </div> 
                   <!-- // Group END --> 
                   <!-- Group --> 
                   <div class="form-group"> 
                    <label class="col-sm-2 control-label" for="lastname">Last name</label> 
                    <div class="col-sm-8"> 
                     <input class="form-control" id="lname" name="lname" type="text"/> 
                    </div> 
                   </div> 
                   <!-- // Group END --> 
                   <!-- Group --> 
                   <div class="form-group"> 
                    <label class="col-sm-2 control-label" for="username">Username</label> 
                    <div class="col-sm-8"> 
                     <input class="form-control" id="user" name="user" type="text"/> 
                    </div> 
                   </div> 
                   <!-- // Group END --> 
                   <!-- Group --> 
                   <div class="form-group"> 
                    <label class="col-sm-2 control-label" for="password">Password</label> 
                    <div class="col-sm-8"> 
                     <input class="form-control" id="pass" name="pass" type="password"/> 
                    </div> 
                   </div> 
                   <!-- // Group END --> 
                   <!-- Group --> 
                   <div class="form-group"> 
                    <label class="col-sm-2 control-label" for="email">E-mail</label> 
                    <div class="col-sm-8"> 
                     <input class="form-control" id="email" name="email" type="email"/> 
                    </div> 
                   </div> 
                   <!-- // Group END --> 
                 </div> 
                 <div class="form-group"> 
                  <div class="col-sm-offset-2 col-sm-10"> 
                  <button type="submit" class="btn btn-success"><i class="fa fa-fw fa-check-square-o"></i> Create</button> 
                 <button type="reset" class="btn btn-danger"><i class="fa fa-fw fa-times"></i> Cancel</button> 
                 </div> 
                 <!-- // Form actions END --> 
                </div> 
              </form> 
             </div> 
            </div> 
           </div> 

这从一些配置/ main.php

'components'=>array(
     'assetManager'=>array(
      'basePath'=>'runtime', 
      ), 
     'user'=>array(
      // enable cookie-based authentication 
      'allowAutoLogin'=>true, 
     ), 
     // uncomment the following to enable URLs in path-format 

     'urlManager'=>array(
      'urlFormat'=>'path', 
      'rules'=>array(
       '<controller:\w+>/<id:\d+>'=>'<controller>/view', 
       '<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>', 
       '<controller:\w+>/<action:\w+>'=>'<controller>/<action>', 
      ), 
     ), 

,这是在.htaccess文件

RewriteEngine on 

php_flag display_startup_errors on 
php_flag display_errors on 
php_flag html_errors on 
php_flag log_errors on 

# if a directory or a file exists, use it directly 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 

# otherwise forward it to index.php 
RewriteRule . index.php 

回答

1

让你的链接是这样的:

$adminCreateUrk = Yii::app()->createUrl('administrator/create'); 
$themeUrl = Yii::app()->createUrl('/theme'); 
+0

我必须删除$ =基本URL的Yii ::应用程序() - > GETBaseUrl(真); ?? – Ken

+0

这是创建网址的标准方式,因为yii可以处理创建,并且您可以在全局范围内进行更改,而不必担心更改应用中的每个链接 – tinybyte

+0

我必须在哪里编写此代码? – Ken