Im stuck again :-/.
While submitting a form, I need some extra data in the controller afterwards, which I have in the view.
So what I’m trying to do is something like that:
echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save', array('entry' => $entry))
… but this doesn’t really work … so it’s just an example what I’m thinking of…
So, as you can see, I would need the entry object later on as well beneath the submitted form. Is there a way to do that? If yes, how can I access that object in the controller?
Thanks in advance,
You cannot pass php objects trought html.
You should pass some parameter and in the controller retrive from the database the object you need.
ahh ok, so how can I pass a parameter? … in this case the ID? Could you give me an example code snippet please?
Tanks so far!
You can change your form action so send the ID of the object your need.
for example you can make your action
$this->createUrl('', array('entry_id' => $entry->id));
which will generate something like ‘?r=currentController/currentAction&entry_id=1’
That way after submitting the form you can retrieve your object from the database
Thanks a lot for your help,
i finally solved it with a hidden field like that:
<?php echo CHtml::activeHiddenField($entry, 'entry_id');?>
which I received in the controller like that:
$entry = Entry::model()->findByPk($_POST['Entry']['entry_id']);