Po odoslani formulara ERROR – Column operator does not accept null argument
- kerafura
- Člen | 9
Zdravim, mam jednoduchy formular na update hodnot v DB, problem je ze ked sa
tento formular odosle, tak to dava chybu
Column operator does not accept null argument
na riadku
->where('dateDec = ? AND startTime = ?', $this->dayDec, $this->startTime)
.
Nedava mi tento problem zmysel, kedze aj v pripade realodu stranky by mali byt
hodnoti pristupne, preto by som bol rad o trochu podrobenjsie vysvetlenie.
public function renderEdit($dayDec, $startTime) {
$this->dayDec = $dayDec;
$this->startTime = $startTime;
}
public function createComponentOrderEdit() {
$form = new form;
$orderDetails = $this->database->table('orders')
->where('dateDec = ? AND startTime = ?', $this->dayDec, $this->startTime)
->fetch();
$this->orderId = $orderDetails->id;
$form->addText('name')
->setDefaultValue($orderDetails->name);
$form->addText('tel')
->setHtmlType('number')
->setDefaultValue($orderDetails->tel);
$form->addEmail('email')
->setDefaultValue($orderDetails->email);
$form->addText('price')
->setHtmlType('number')
->setDefaultValue($orderDetails->price);
$form->addText('deposit')
->setHtmlType('number')
->setDefaultValue($orderDetails->deposit);
$form->addText('comment')
->setDefaultValue($orderDetails->comment);
$form->addSubmit('submit');
$form->onSuccess[] = [$this, 'orderEditSucceeded'];
return $form;
}
public function orderEditSucceeded($form)
{
$values = $form->getValues();
$this->database->table('orders')->where('id', $this->orderId)->update([
'price' => $values['price'],
'deposit' => $values['deposit'],
'name' => $values['name'],
'tel' => $values['tel'],
'email' => $values['email'],
'comment' => $values['comment'],
]);
$this->redirect('Calendar:');
}
Editoval kerafura (22. 2. 2018 12:59)
- David Matějka
- Moderator | 6445
renderEdit se vykonava az po zpracovani formulare, prepis to na actionEdit