Array Value For Cactiveform Hidden Field


<?php $form=$this->beginWidget('CActiveForm', array(





	'clientOptions' => array(




)); ?>

<?php echo $form->hiddenField($model,'MyArray'); ?> 

<?php $this->endWidget(); ?>

‘MyArray’ is an array value. How can i implement as hidden fields takes only string value.

You have to declare the value in the model :

class MyClass extends QActiveRecord {

    public $MyArray;

I have declared it in

class MyClass extends CActiveRecord {

    public $MyArray;

I get an Error Parameter string needed

What is QactiveRecord Didnt find it in Class reference

oh I am sorry CActiveRecord is CActiveRecord in fact.

But can you explain a bit about what you want do to?

Hi I have a hidden field in form that POST an array value. But the problem is in CActiveFrom hidden you can pass a string and not array value

You’d have to use your own function since (like you said) hiddenfield only supports strings.

Just out of curiosity, what would be the expected output of the function?

Well I want to send an array to the controller and save it in my mongodb as array

Dear Friend

Check whether the following is helpful.

In your controller actionCreate or actionUpdate method

public function actionUpdate()









			//$model->arr=implode(",",$model->arr);//here if validation fails for other attributes, kindly ensure that it is again converted to string.









Thanks It works :)