Answer the question
In order to leave comments, you need to log in
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
<?= $form->field($feedback, 'name', $template_input)->textInput(['placeholder' => 'Ваше Имя', 'class'=>''])->label(''); ?>
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'));
}
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question