$this->render(‘show’,array(‘message’=>$message));
I am trying to display "hello world" string using the above statement.
my total code of the MessageController is :
<?php
class MessageController extends Controller
{
public function actionShow()
{
// create a new instance of MessageForm model
$message=new MessageForm;
/*
* check to see if the MessageForm fields were filled in
*
* If they were, then print out the message and author
* with the show render - based on what the user inputted
*
* If not, then print out the default hellow world and
* default author with the show render.
*/
if(isset($message->message))
$this->render('show',array('message'=>$message));
else
{
$message->message = "Hello World";
$message->author = "Default Author";
$this->render('show',array('message'=>$message));
}
public function actionError()
{
if($error=Yii::app()->errorHandler->error)
{
if(Yii::app()->request->isAjaxRequest)
echo $error['message'];
else
$this->render('error', $error);
}
}
public function actionEdit()
{
// create a new instance of MessageForm model
$message=new MessageForm;
/*
* check to see if All the fileds are filled in on the form
* if so proceed to assign the values to the variables in the message model (author and message)
*
* If they validate (no errors) then render the show page with the new data values
*
* If there's errors, return to the edit form showing the errors
*
* Finally if the form wasn't set then we render the edit page so that the user can input field values.
*/
if(isset($_POST['MessageForm']))
{
$message->attributes=$_POST['MessageForm'];
if($message->validate())
$this->render('show',array('message'=>$message));
else
$this->render('edit', array('message'=>$message));
}
else
$this->render('edit', array('message'=>$message));
}
public function actionIndex()
{
$this->render('index');
}
public function actionSubmit()
{
$this->render('index');
}
}
can anyone help me plzzzzzzzzzzzzzzzz