M
M
Michael2020-06-29 10:38:38
Yii
Michael, 2020-06-29 10:38:38

What causes the strpos() expects parameter 1 to be string, array given error?

Hello! Please help me with the following problem

strpos() expects parameter 1 to be string, array given

It crashes on the following line:
<?= $form->field($feedback, 'name', $template_input)->textInput(['placeholder' => 'Ваше Имя', 'class'=>''])->label(''); ?>

controller
public function actionFeedback()
{
    $feedback = new Feedback();
    if(\Yii::$app->request->isAjax && $feedback->load(Yii::$app->request->post()) && $feedback->save() && $feedback->contact(Yii::$app->params['adminEmail'])){
        return $this->refresh();
    }
    if($feedback->load(\Yii::$app->request->post())){
        var_dump($feedback);
    }
    return $this->render('index', compact('feedback'));
}

model
public function contact($adminEmail)
{
    if ($this->validate()) {
        Yii::$app->mailer->compose()
            ->setTo($adminEmail)
            ->setFrom([Yii::$app->params['adminEmail'] => Yii::$app->params['senderName']])
            ->setSubject('Сообщение с сайта')
            ->setTextBody("Имя: ".$this->name."\n Телефон: ".$this->phone."\n Емайл:".$this->email."\n Текст:".$this->message)
            ->send();
        return true;
    } else {
        return false;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim, 2020-06-29
@Bally

1 passed parameter is expected to be a string, and there is an array.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question