S
S
SeiLove2015-12-24 12:16:11
Yii
SeiLove, 2015-12-24 12:16:11

How to make the widget action work?

Good afternoon! Faced a strange problem - the action does not want to work on the widget. I'm trying to make a popup form according to the manual.
'action' => array('/store/quick')
this is how I call it.
and quick.php respectively in the store folder... but when clicked, a blank page opens.
action code (taken from the manual, did not change anything)

public function actionQuick() {
        $model=new QuickForm;
            $model->attributes=$_POST['QuickForm'];
            if($model->validate()) {
                $headers="From: [email protected]\r\nReply-To: [email protected]";
                $body = "\n\nОтправитель: ".$model->name."\t Телефон: ".$model->phone."\t Время звонка: ".$model->timeToCall;
                mail('[email protected]','ПЕРЕЗВОН!',$body,$headers);
      
          $this->redirect(array('site/index'));
            }
        $this->redirect(array('site/index'));
}

I tried to attach actions to the controller... but I did something incomprehensible On click, the entire action code was "displayed" as it is on the page. Maybe he worked with the action incorrectly? ..
Call code
public function actions() {
    
    
    return array(
                        'my' => 'frontend.controllers.quick2',
                );
    }

and action class code
class quick2 extends CAction
{
        public function run()
        {
                      $model=new QuickForm();
if(isset($_POST['QuickForm']))
{    
$model->attributes=$_POST['QuickForm'];
           if($model->validate()) {
               $headers="From: $model->email\r\nReply-To: $model->email";
               $body = "\n\nОтправитель: ".$model->name."\t Телефон: ".$model->phone."\t Email: ".$model->email."\t Задача: ".$model->message;
             //  mail(Yii::app()->params['adminEmail'],'Письмо с сайта loco.ru от '.$model->name, $body, $headers, '-f [email protected]');
        mail('[email protected]','Письмо с сайта loco.ru от '.$model->name, $body, $headers, '-f [email protected]');
       
       Dialog::message('flash-success', 'Отправлено!', 'Спасибо, '.$model->name.'! Ваше письмо отправлено!');
  $this->redirect(array('site/index'));
}
}
  $this->redirect(array('site/index'));

        }
}

Can someone tell me what the trouble is, had to deal with this)) Or tell me how to properly attach the action class to the controller, maybe I messed up at this level?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question