Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** @var Table\ActiveRow */
- private $user;
- public function actionDefault($id)
- {
- $this->user = $this->db->table('user')->get($id);
- if (!$this['form']->isSubmitted()) { // nevolat databázi zbytečně
- $this['form']->setDefaults(array(
- 'user' => array(
- 'home' => $this->user->home->toArray(),
- 'correspondence' => $this->user->correspondence->toArray(),
- 'billing' => $this->user->billing->toArray(),
- ) + $this->user->toArray()
- ));
- }
- }
- protected function createComponentForm()
- {
- $form = new UI\Form;
- $form['user'] = new UserContainer;
- $form['user']['home'] = new AddressContainer;
- $form['user']['correspondence'] = new AddressContainer;
- $form['user']['billing'] = new AddressContainer;
- $form->addSubmit();
- $form->onSuccess[] = $this->formSubmitted;
- return $form;
- }
- public function formSubmitted(UI\Form $form)
- {
- // validace
- // user
- $user = $form->values['user'];
- unset($user['billing'], $user['home'], $user['correspondence']);
- $this->user->update($user);
- // address
- $this->user->home->update($form->values['user']['home']);
- $this->user->billing->update($form->values['user']['billing']);
- $this->user->correspondence->update($form->values['user']['correspondence']);
- $this->redirect(...
- }
Advertisement
Add Comment
Please, Sign In to add comment