Yii多个相关模型

时间:2014-10-03 11:41:14

标签: php yii relationship

我需要能够在注册表单上添加大量地址。我使用了这个example,但它显示错误:

Argument 4 passed to CClientScript::registerScript() must be of the type array, integer given, called in /var/www/yii/protected/views/user/_form.php on line 77 and defined

user / _form.php的一部分

<div id="address">

</div>

<?php echo CHtml::link('Add Child', '#', array('id' => 'loadChildByAjax')); ?>

<?php
    Yii::app()->clientScript->registerCoreScript('jquery');
    Yii::app()->clientScript->registerScript('loadchild', '
        $(document).ready(function(){
            $("#loadChildByAjax").click(function(e){
            e.preventDefault();
            var _url = "' . Yii::app()->controller->createUrl("loadChildByAjax"), '
            $.ajax({
                method: GET,
                url: _url,
                dataType: html,
                success:function(data){
                    $("#address").append(data);
                }
            });
        });
        });
    ', CClientScript::POS_END);
?>

有什么问题?

1 个答案:

答案 0 :(得分:0)

var _url = "' . Yii::app()->controller->createUrl("loadChildByAjax"), '

应该是

var _url = "' . Yii::app()->controller->createUrl("loadChildByAjax"). '";
我猜想。