submitLink question

244 views
Skip to first unread message

sol

unread,
Sep 9, 2012, 3:48:38 PM9/9/12
to yii-bo...@googlegroups.com
Greetings...  I am converting the views for yii-user and yii-rights to leverage this module... it's starting to look really nice.  (happy to contribute back for anyone that would want it).

I am having a little trouble with converting one item that when rendered with the CMenu widget, works, but I can not seem to get it to work with TbButton.

Here is the original code from the yii-user module view:

$this->menu=array(
    array('label'=>UserModule::t('Delete User'), 'url'=>'#','linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>UserModule::t('Are you sure to delete this item?')))
);

Here is how I currently have it in my theme/view:

$this->widget('bootstrap.widgets.TbButton', array(
'buttonType'=>'link',
'icon'=>'trash',
'type'=>'danger',
'label'=>UserModule::t('Delete User'), 
'url'=>array('delete','id'=>$model->id),
'htmlOptions'=>array('confirm'=>UserModule::t('Are you sure to delete this item?')),
'size'=>'Large'
));

It does the prompt,but then goes to the URL (which requires a POST not a GET).  Any advice?

Many Thanks.  And Chris -> Love this module and yii-rights... thank you for your constant contributions.

~SOL

smyiia

unread,
Sep 25, 2012, 4:38:24 AM9/25/12
to yii-bo...@googlegroups.com
Hola,
He comentado algunas lineas, y funciona, aun no tengo una respuesta especifica.
public function actionDelete($id)
{
$this->loadModel($id)->delete();
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
// if(Yii::app()->request->isPostRequest)
// {
// // we only allow deletion via POST request
// $this->loadModel($id)->delete();

// // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
// if(!isset($_GET['ajax']))
// $this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
// }
// else
// throw new CHttpException(400,'Invalid request. Please do not repeat this request again.');
}
saludos
 

smyiia

unread,
Sep 25, 2012, 6:10:19 AM9/25/12
to yii-bo...@googlegroups.com


El domingo, 9 de septiembre de 2012 21:48:38 UTC+2, sol escribió:
public function actionDelete($id)
{
if(Yii::app()->request->isPostRequest)
{
//we only allow deletion via POST request
$this->loadModel($id)->delete();

// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
if(!isset($_GET['ajax']))
$this->redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
}
else{
if (isset($_GET['id'])){
$this->loadModel($id)->delete();
$this->redirect(array('admin'));
}else

smyiia

unread,
Sep 25, 2012, 6:11:21 AM9/25/12
to yii-bo...@googlegroups.com


El domingo, 9 de septiembre de 2012 21:48:38 UTC+2, sol escribió:

Alfonso Ramos

unread,
Aug 21, 2013, 6:32:45 AM8/21/13
to yii-bo...@googlegroups.com
Cambia 'linkOptions' por 'htmlOptions'


El domingo, 9 de septiembre de 2012 21:48:38 UTC+2, sol escribió:

Alec Kor

unread,
Oct 6, 2013, 9:20:20 PM10/6/13
to yii-bo...@googlegroups.com
Thanks, this is the answer that i am looking for.
Reply all
Reply to author
Forward
0 new messages