public function actionUpdate($id) { $model = new Transport(); $model = $model->find($id); $passport = $model->getRelatePassport(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $data = $_POST; $model = $model->fromArray($data); $model->save(); $data['id'] = $passport->getId(); $data['id_transport'] = $model->getId(); $passport = $passport->fromArray($data); $passport->save(); header('Location: /'); } else { $vendors = new Vendor(); $vendors = $vendors->findAll(); $properties = new Properties(); $allProperties = $properties->findAll(); $transportProperties = $model->getRelateProperties(); $propDiff = $this->arrayOfObjectDifference($allProperties, $transportProperties); $template = $this->twig->loadTemplate('transport/update.tpl'); echo $template->render(array('model' => $model, 'vendors' => $vendors, 'passport' => $passport, 'propDiff' => $propDiff, 'transportProperties' => $transportProperties)); } }
public function actionUpdate($id) { $properties = new Properties(); $properties = $properties->find($id); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $properties = $properties->fromArray($_POST); $properties->save(); header('Location: /'); } else { $template = $this->twig->loadTemplate('properties/update.tpl'); echo $template->render(array('model' => $properties, 'types' => Properties::getTypes())); } }