I have a form with one element named 'title', and code is
<?php
$form = new MyForm();
$form->bind(['title' => '1122'], $form);
foreach ($form->getElements() as $v) {
echo $v->getName().':'.$v->getValue();
}
the output is "title:1122"
but when I use this code in post method
<?php
if ($this->request->isPost()) {
$form = new MyForm();
$form->bind($this->request->getPost(), $form);
foreach ($form->getElements() as $v) {
echo $v->getName().':'.$v->getValue();
}
}
I can't get the value, even I change code like this
<?php
if ($this->request->isPost()) {
$form = new MyForm();
$form->bind(['title' => '1122'], $form);
foreach ($form->getElements() as $v) {
echo $v->getName().':'.$v->getValue();
}
}
I still can't get the value, I must write $form->getValue($v->getName()) to get the value. that make me crazy.