Очередной новичок, копаюсь в YII целыми днями и столкнулся с проблемой. После отправки формы методом $_POST, выдается ошибка связанная непосредственно с редиректом: Cannot modify header information - headers already sent by (output started at C:\yii\framework\web\CController.php:793).
Файлы с контролером, моделью и представлением в UTF-8 without BOM. Файл CController.php, так же преоброзовал в UTF-8 w/o BOM(до этого тоже не работало). Тег ?> везде закрываю.
Итак, код контроллера:
Код: Выделить всё
<?php
class MonstersController extends Controller
{
public function actionIndex()
{
$model=new Monsters;
$this->render('monsters', array('model'=>$model)); //строка передающая визуализацию странице monsters
$model->actionRegistration();
}
}
?>
Код: Выделить всё
<?php
class Monsters extends CActiveRecord
{
public function tableName()
{
return 'monsters';
}
public function rules()
{
return array(
array('login, password, email', 'required'),
array('login, password, email', 'length', 'min'=>4, 'max'=>32),
array('id, login, password, email', 'safe', 'on'=>'search'),
);
}
public function relations()
{
return array(
);
}
public function attributeLabels()
{
return array(
'id' => 'ID',
'login' => 'Логин',
'password' => 'Пароль',
'email' => 'Электроная почта',
);
}
public function search()
{
$criteria=new CDbCriteria;
$criteria->compare('id',$this->id);
$criteria->compare('login',$this->login,true);
$criteria->compare('password',$this->password,true);
$criteria->compare('email',$this->email,true);
return new CActiveDataProvider($this, array(
'criteria'=>$criteria,
));
}
public static function model($className=__CLASS__)
{
return parent::model($className);
}
public function actionRegistration() {
$q=new Monsters;
$w=new MonstersController(MonstersController);
if(isset($_POST['Monsters'])) {
$q->attributes=$_POST['Monsters'];
$q->login=$_POST['Monsters']['login'];
$q->password=$_POST['Monsters']['password'];
$q->email=$_POST['Monsters']['email'];
$q->save();
}
if($q->save()) {
Yii::app()->user->setFlash('tipDay','Данные сохранены');
$w->redirect(array('index','id'=>'val1'));
}
}
}
?>