[font="Courier New"]Hi,
I’m following this: yiiframework.com/doc-2.0/guide-start-forms.html
(No full links because the forum software says since I’m new I can’t post links)
Problem:
Works: localhost/~dev/hello/web/index.php?r=site/say-something
Doesn’t work: localhost/~dev/hello/web/index.php?r=site/entry , Gives blank output.
In controllers/SiteController.php:
public function actionSaySomething()
{
$msg = "finally working on yii !";
return $this->render('say-something', array('msg'=>$msg));
}
public function actionEntry() {
$model = new EntryForm();
$model->name = 'Random';
$model->email = 'notanemail';
if ($model->validate()) {
$retVal = 'yay';
} else {
$retVal = $model->getErrors();
}
error_log(print_r($retVal, true));
$this->render('entry', ['model'=>$model] );
}
In view/say-something.php:
<?php
use yii\helpers\Html;
?>
<?=Html::encode($msg); ?>
In views/entry.php:
<?php
use yii\helpers\Html;
?>
<?php print_r($model->getErrors()); ?>
<p>You have entered the following information...</p>
<?php // exit; ?>
<ul>
<li><label>Name</label>: <?= Html::encode($model->name); ?></li>
<li><label>Email</label>: <?= Html::encode($model->email); ?></li>
</ul>
If I uncomment the "exit;" in views/entry.php I can see this:
Array ( [email] => Array ( [0] => Email is not a valid email address. ) )
You have entered the following information…
But if I try to display the error, I cannot, I get a blank output.
The error_log() logs the proper output($m to the apache log file.
This has to be a very basic thing I am missing.
Thanks in advance,
Dave
[/font]