Yii渲染模态问题

时间:2014-07-03 04:05:19

标签: php .htaccess url yii url-rewriting

我有创建管理员的模态表单。来自该模态的所有数据都可以正确保存在数据库中,但问题是当我想要转到另一个链接时,它会收到错误并显示一些弹出式错误!'

示例:首先我转到://.../administrator然后我点击按钮'创建'要显示'创建模式',我完成所有表单,我点击提交然后我想去://.../theme,问题在这里,我不能去: //.../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>

这一些来自config / 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 个答案:

答案 0 :(得分:1)

制作如下链接:

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