Question

following is my code in view but i am unable to create button in cgridview

   <?php echo CHtml::link('Advanced Search','#',array('class'=>'search-button')); ?>
    <div class="search-form" style="display:none">
    <?php $this->renderPartial('_search',array(
'model'=>$model,
      )); ?>
    </div><!-- search-form -->

    <?php $this->widget('zii.widgets.grid.CGridView', array(
'id'=>'product-grid',
'dataProvider'=>$model->countregister($_GET['id']),
'enablePagination' => true,
'filter'=>$model,
'columns'=>array(

    'name',
    'email',





    array(
        'class'=>'CButtonColumn',
        'template'=>'{Register}{update}{view}',

        'buttons'=>array(
               'Register'=>array(
               'label'=>'Register',
               'url'=>Yii::app()->createUrl('register/create',array(
                'id'=>$_GET['id'],
               'rid'=>$_GET['rid']
               ))
              )
               ),

    ),

    ),
     )); ?>

passed rid to query string i am getting this error

  Parse error: syntax error, unexpected '/' in D:\wamp\www\yii\framework\base\CComponent.php(612) : eval()'d               code on line 1

the register button appears with the above error but if click doesnt go to the specified URL

PLEASE HELP let me know how can i make up

Was it helpful?

Solution

change your code to this

<?php    $id=$_GET['id'];
            $rid=$_GET['rid'];  ?>
                <?php $this->widget('zii.widgets.grid.CGridView', array(
// rest of your code

'url'=>"Yii::app()->createUrl('register/create',array(
                'id'=>$id,
               'rid'=>$rid
               ))"

more details

'buttonID' => array
(
    'label'=>'...',     //Text label of the button.
    'url'=>'...',       //A PHP expression for generating the URL of the button.
    'imageUrl'=>'...',  //Image URL of the button.
    'options'=>array(), //HTML options for the button tag.
    'click'=>'...',     //A JS function to be invoked when the button is clicked.
    'visible'=>'...',   //A PHP expression for determining whether the button is visible.
)

OTHER TIPS

you have a typo, change

 'url'=>Yii::app()->request->baseUrl.'/index.php?r=register/create&id='.$_GET['id'].'&rid='Yii::app()->user->userid))',

to:

 'url' => Yii::app()->request->baseUrl . '/index.php?r=register/create&id=' . $_GET['id'] . '&rid=' . Yii::app()->user->userid)),

use a better IDE to help you with this kind of errors

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top