k123456
(Kassa 923)
July 3, 2013, 4:32pm
1
hello everyone im quite new to YII and ive got a problem calling an action
I have a php page inside views/site/home.php which is expected to present a set of set of buttons for each user logged in.
in my view i have the code:-
else if(Yii::app()->user->title=='admin')
{
?>
<div class="row">
<?php echo CHtml::submitButton('Students', array('submit'=>$this->createUrl( 'student' ),'class'=>'buttonstd')); ?>
</div>
This is a image button, i have an internal css defined as well.
In my siteController.php
public function actionStudent()
{
$model= new Students;
$this->render('/students/create',array('model'=>$model));
}
This code is expected to view the create page, but i get a error saying
Can someone help me get it right, i mean the theory looks correct. Any help is greatly appreciated.
Thanks a lot.
Cheerz!
menxaca
(Menxaca)
July 3, 2013, 5:03pm
2
I’m not an expert and not sure but… instead of using CHtml::submitButton, try to use CHtml::link. If you don’t have any form inputs you should not use submit.
k123456
(Kassa 923)
July 3, 2013, 5:12pm
3
@menxaca - Thanks for the reply,
Yeah, link can be used, i had the links in a CMenu widget and it worked.
but now i need to get the user to press an image button instead.
Gave it a try but didnt work so far…
Thanks anyways…
Cheerz!
menxaca
(Menxaca)
July 3, 2013, 5:25pm
4
You can use CHtml::link with an image:
echo CHtml::link(CHtml::image('url for src property', 'text for alt property'), Yii::app()->createUrl('student')));
k123456
(Kassa 923)
July 4, 2013, 8:09am
5
menxaca:
You can use CHtml::link with an image:
echo CHtml::link(CHtml::image('url for src property', 'text for alt property'), Yii::app()->createUrl('student')));
@menxaca - Yup, this way it worked. Thanks a lot for your time!
Cheerz! !