zii.widgets.CMenu and 'submit' link

I discovered that it is possible to create a "delete" link (or for other cases which is submitting a post request using Chtml:link.


CHtml::link('Delete', '#',

	array('submit' => array('item/delete', 'id'=>$model->id), 'confirm' => 'Sure')

);

Is it possible to use this within a zii.widgets.CMenu as well? If yes, how?

This is what I use at the moment:


$this->widget('zii.widgets.CMenu',array(

	'items'=>array(

		array('label'=>'Löschen', 'url'=>array('/item/delete', 'id' => $model->id)),

	)

);

I think linkOptions can help your.

Thanks, that works.




$this->widget('zii.widgets.CMenu',array( 'items'=>array(

array('label'=>'Delete', 'url'=>'#',

    'linkOptions'=>array(

        'submit' => array('item/delete', 'id'=>$item->id), 'confirm' => 'Delete?'),

        'visible'=>!Yii::app()->user->isGuest),

),

);

Thanks, this was very helpful for me as well. I’d like to point out a slight fix to your sample code, to give an example of correct parentheses/parameters passed to to linkOptions.




$this->widget('zii.widgets.CMenu', array(

    'items'=>array(

        array(

            'label'=>'Delete', 

            'url'=>'#',

            'linkOptions'=>array(

                'submit' => array('item/delete', 'id'=>$item->id), 

                'confirm' => 'Delete?',

                'visible'=>!Yii::app()->user->isGuest

            ),

        ),

    ), 

));