setFlash not working with POST

this is not working in 1.1.9




$message = CHtml::link('Undo', '#',array('submit'=>array('trash/restore/id/'.$model->id)));

Yii::app()->user->setFlash('success', $message);



Yii creates a wrong id for the link (a tag, same bug with button though). this id can already be used by another ajax call in the page: the link will then submit a wrong action (ie won’t work as expected)…

would you consider that a bug?

If you mean on the HTML id that is generated for the link automatically… the only solution is to set a custom one as Yii always starts the automatic numbering from the beginning on every request (ajax call)

if I add a custom "test1" id, Yii should automatically write this code in the jquery ready function, but it does not:




$('body').on('click','#test1',function(){jQuery.yii.submitForm(this,'/test/trash/restore/class/Gallery/id/30',{});return false;});



if i paste the same code outside the setFlash() it does. this code generated the above javascript:




echo CHtml::link('Undo','#',array('submit'=>array('trash/restore/class/Gallery/id/30'), 'id'=>'test1'));



problem is that the jQuery code is not returned by the link() call… the link() method returns the HTML code… the JS code is rendered with clientscript… so those are two different things…

For this you should write your custom jQuery code and assign it to setFlash().

ok thank you mdomba.

It;s Working[color=#000000]echo [/color][color=#660066]CHtml[/color][color=#666600]::[/color][color=#000000]link[/color][color=#666600]([/color][color=#008800]‘Undo’[/color][color=#666600],[/color][color=#008800]’#’[/color][color=#666600],[/color][color=#000000]array[/color][color=#666600]([/color][color=#008800]‘submit’[/color][color=#666600]=>[/color][color=#000000]array[/color]color=#666600,[/color][color=#000000] [/color][color=#008800]‘id’[/color][color=#666600]=>[/color][color=#008800]‘test1’[/color][color=#666600]));[/color]