"Call to a member function isAttributeRequired() on a non-object in CHtml.php" when using Array of Embedded Documents

297 views
Skip to first unread message

Mahesh S

unread,
Jun 3, 2012, 8:18:29 AM6/3/12
to yiimong...@googlegroups.com


In my model i defined the behaviors() like this:

public function behaviors()

    {

        return array(

            'embeddedArrays' => array(

                'class'=>'ext.YiiMongoDbSuite.extra.EEmbeddedArraysBehavior',

                'arrayPropertyName'=>'address',       // name of property, that will be used as an array

                'arrayDocClassName'=>'UserAddress'    // class name of embedded documents in array

            ),

        );

    }

Also i made a model UserAddress.php and in the view file(_form.php), i gave as:

<div class="row">

<?php echo $form->labelEx($user->address[0],'city'); ?>

<?php echo $form->textField($user->address[0],'city'); ?>

<?php echo $form->error($user->address[0],'city'); ?>

</div>

<div class="row">

<?php echo $form->labelEx($user->address[0],'zip'); ?>

<?php echo $form->textField($user->address[0],'zip'); ?>

<?php echo $form->error($user->address[0],'zip'); ?>

</div>

<div class="row">

<?php echo $form->labelEx($user->address[0],'street'); ?>

<?php echo $form->textField($user->address[0],'street'); ?>

<?php echo $form->error($user->address[0],'street'); ?>

</div> 

But I get error as in the below image.

Can anyone help me on this?
Reply all
Reply to author
Forward
0 new messages