[solved] how to set Value of CActiveForm -> hidden field


i’m using an Widget to greate an CActiveForm, like this:

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






Part of this form are some hidden fields, which should be filed with an value:

echo $form->hiddenField($model,'matchID',array('value'=>'123'));

The Point is: the hidden input field is renderd as an part of the form, but the value is not set.

Is there any typo, I don’t see??

I’m thinking about this problem since an hour but can’t find the reason.

The renderd HTML Code looks like this:

<input id="Mymodel_matchID" type="hidden" name="Mymodel[matchID]" value=" ">

As you can see: value is an "space".

But why?

Thank you rall0r

//Edit: it looks like, CActiveForm removes all the values an set it to " ". Is this possible?

The following "works"

echo $form->hiddenField($model,'matchID',array('XXvalue'=>'123'));

Here XXvalue get’s the value 123. But CActivForm doesn’t post XXvalue to the Form-action. (which is correct)

Maybe it’s linked to your action. Are you in create or update mode?

I’ve been using your syntax without any problem.

Not sure.

I simple initialize the model on action side like this:

(abstract code)

$model= new Mymodel();


                'model' => $model,


//Edit adding $model->isnewrecord=false; on action side, there is no effect.

And does it work with the standard Gii CRUD? There are several differences between your code and Gii’s one, maybe you can start with the standard to see what is wrong?

That looks like it should work ok.

You could try this,

$model->matchID = 123;

echo $form->hiddenField($model,'matchID');

$model->matchID = 123;

i have tried this before: on action side, insight the view and insight the widget: nothing works.

not sure, I never tried. What dou you think - what is missing from the default Gii output?

Has nobody any idea what’s wrong here?

If the code (i worte) is correct, so where could be the problem?

Maybe I use the widget in an wrong way?

Unfortunately the documentation is not very useful in all cases, like this:


Btw: the description of "$attribute" is: "the attribute".

At school i learnd: never explan something with itself. :wink:

So for me, as an non native english person it sometimes hard to understand, what the documentation real tries to say.

//Edit: I found the error i did - bases on JS code I worte.

So at all: thank you for supporting and "sorry" about that layer-8 problem.

I’m having exactly the same issue here. How did you fix it? Which js caused this issue?