<?php

// dedicnost vs kompozice

// dedicnost
class PersonForm extends Nette\Application\UI\Form
{
	public function __construct()
	{
		parent::__construct();

		$this->addText('name', 'Jméno');
		$this->addSubmit('submit', 'Odeslat');
	}
}

class PersonWithAddressForm extends PersonForm
{
	public function __construct()
	{
		parent::__construct();

		$this->addText('city', 'Město');
		$this->addText('street', 'Ulice');
	}
}


// kompozice
class PersonContainer extends Nette\Forms\Container
{
	public function __construct()
	{
		parent::__construct();

		$this->addText('name', 'Jméno');
		$this->addText('surname', 'Příjmení');
	}
}


class AddressContainer extends Nette\Forms\Container
{
	public function __construct()
	{
		parent::__construct();

		$this->addText('city', 'Město');
		$this->addText('street', 'Ulice');
	}
}


// USAGE
class MyPresenter extends BasePresenter
{
	protected function createComponentPersonWithAddressForm()
	{
		$form = new Nette\Application\UI\Form;
		$form['user'] = new PersonContainer();
		$form['user']['address'] = new AddressContainer();
		$form['user']['correspondence'] = new AddressContainer();
		$form['user']['billing'] = new AddressContainer();

		$form->addSubmit('submit', 'Odeslat');
		$form->onSuccess[] = function () {};

		return $form;
	}
}

// nebo tovarna
class MyPresenter extends BasePresenter
{	
	public function __construct()		protected function createComponentPersonWithAddressForm()
	{		{
		parent::__construct();			$form = new Nette\Application\UI\Form;
		$form['user'] = new PersonContainer();
		$form['user']['address'] = new AddressContainer();
		$form['user']['correspondence'] = new AddressContainer();
		$form['user']['billing'] = new AddressContainer();


		$this['user'] = new PersonContainer();			$form->addSubmit('submit', 'Odeslat');
		$this['user']['address'] = new AddressContainer();			$form->onSuccess[] = function () {};
		$this['user']['correspondence'] = new AddressContainer();	
		$this['user']['billing'] = new AddressContainer();	


		$this->addSubmit('submit', 'Odeslat');			return $form;
	}		}
}