Calling A Controller Action Issue

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')); ?>


This is a image button, i have an internal css defined as well.

In my siteController.php

public function actionStudent()


            $model= new Students;



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! :)

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.

@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! :)

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! :)!