Newbie here. CHTML::Button adding many characters. I can’t figure it out.
I am trying to pass the portfolio_id to another form. Once a user selects a portfolio, the button should take him to another form (another model/controller) to input child records. Portfolio_id then becomes foreign key in the other table and should prepopulate the model with that value. But on click, i thought i would get:
url…blablabla/ id=2
but, this is what i get as a url:
url… /create?0%5Bid%5D=2
added characters and percent signs. $_GET does not pick it up. I get an undefined index error.
Database tables:
Portfolio (id, name, desc) and project (id, name, desc, portfolio_id). relationship - a portfolio may contain many projects. Project can only be associated with one project.
My portfolio form code:
<h1>View Portfolio <?php echo $model->name; ?></h1>
<?php $this->widget(‘zii.widgets.CDetailView’, array(
'data'=>$model,
'attributes'=>array(
'id',
'tenant_id',
'name',
'description',
),
)); ?>
<?php echo CHtml::Button(‘Add Projects to Portfolio’, array(‘submit’ => array(‘projectPortfolio/create’, array(‘id’=>$this->id))));?>
<?php print_r($_GET[‘id’]);?>
project controller
if (isset($GET[‘portfolioId’]))
$model->portfolio_id=($_GET[‘id’]);
What am i missing here?