protected function createComponent($name)
 {
     switch ($name) {
         case 'attachment':
             return new AttachmentControl();
             break;
         default:
             return parent::createComponent($name);
             break;
     }
 }
 /**
  * A little componen factory
  * @param string
  */
 public function createComponent($name)
 {
     switch ($name) {
         case 'dataForm':
             $data = isset(Environment::getSession(SESSION_ORDER_NS)->data) ? Environment::getSession(SESSION_ORDER_NS)->data : array();
             $form = new AppForm($this, $name);
             // contacts
             $form->addGroup(__('Contacts'));
             $form->addText('email', __('E-mail:'))->setEmptyValue('@')->addRule(Form::FILLED, __('You have to enter your e-mail.'))->addRule(Form::EMAIL, __('This is not an e-mail address.'));
             $form->addText('phone', __('Phone number:'))->addRule(Form::FILLED, __('You have to enter your phone number.'))->addRule(Form::NUMERIC, __('Phone number has to be number.'));
             // payer
             $form->addGroup(__('Payer'));
             $form->addText('payer_name', __('Name:'))->addRule(Form::FILLED, __('You have to enter your name.'));
             $form->addText('payer_lastname', __('Last name:'))->addRule(Form::FILLED, __('You have to enter your last name.'));
             $form->addText('payer_company', __('Company:'));
             $form->addText('payer_street', __('Street:'))->addRule(Form::FILLED, __('You have to enter your street.'));
             $form->addText('payer_city', __('City:'))->addRule(Form::FILLED, __('You have to enter your city.'));
             $form->addText('payer_postcode', __('Post code:'))->addRule(Form::FILLED, __('You have to enter your post code.'))->addRule(Form::NUMERIC, __('Post code has to be number.'));
             $form->addCheckbox('same_delivery', __('deliver at same address (you do not need to fill Delivery address below)'))->setValue(TRUE);
             // delivery address
             $form->addGroup(__('Delivery address'));
             $form->addText('delivery_name', __('Name:'))->addConditionOn($form['same_delivery'], Form::EQUAL, FALSE)->addRule(Form::FILLED, __('You have to enter your name.'));
             $form->addText('delivery_lastname', __('Last name:'))->addConditionOn($form['same_delivery'], Form::EQUAL, FALSE)->addRule(Form::FILLED, __('You have to enter your last name.'));
             $form->addText('delivery_street', __('Street:'))->addConditionOn($form['same_delivery'], Form::EQUAL, FALSE)->addRule(Form::FILLED, __('You have to enter your street.'));
             $form->addText('delivery_city', __('City:'))->addConditionOn($form['same_delivery'], Form::EQUAL, FALSE)->addRule(Form::FILLED, __('You have to enter your city.'));
             $form->addText('delivery_postcode', __('Post code:'))->addConditionOn($form['same_delivery'], Form::EQUAL, FALSE)->addRule(Form::FILLED, __('You have to enter your post code.'))->addRule(Form::NUMERIC, __('Post code has to be number.'));
             // delivery type
             $form->addGroup(__('Delivery type'));
             $delivery_types = array();
             foreach (mapper::order_delivery_types()->findAll() as $delivery_type) {
                 $delivery_types[$delivery_type->getId()] = $delivery_type->getName() . Environment::expand(' (' . $delivery_type->getPrice() . ' %currency%)');
             }
             $form->addSelect('delivery_type', __('Type:'), $delivery_types);
             // payment type
             $form->addGroup(__('Payment type'));
             $payment_types = array();
             foreach (mapper::order_payment_types()->findAll() as $payment_type) {
                 $payment_types[$payment_type->getId()] = $payment_type->getName() . Environment::expand(' (' . $payment_type->getPrice() . ' %currency%)');
             }
             $form->addSelect('payment_type', __('Type:'), $payment_types);
             // comment
             $form->addGroup(__('Comment'));
             $form->addTextarea('comment', __('Comment:'));
             // submit
             $form->setCurrentGroup(NULL);
             $form->addSubmit('ok', '(3/3) ' . __('Complete order »'));
             $form['ok']->setRendered(TRUE);
             $form->onSubmit[] = array($this, 'onDataFormSubmit');
             // defaults
             if (isset(Environment::getSession(SESSION_ORDER_NS)->data)) {
                 $form->setDefaults(Environment::getSession(SESSION_ORDER_NS)->data);
             }
             break;
         default:
             parent::createComponent($name);
     }
 }
 function createComponent($name)
 {
     switch ($name) {
         case 'fullOrderForm':
             $form = $this->createComponent('userBaseForm');
             unset($form['login'], $form['password'], $form['passwordCheck']);
             //			 $form['login']->getElementPrototype()->setText('sss');
             //platobne podmienky
             $form->addGroup('');
             //			 $form->addRadioList('payment_method', _('Spôsob platby'), $this->payment_method)
             //					 ->addRule(NForm::FILLED, 'Musíte zvoliť spôsob platby');
             //
             ////			 $form->addGroup('');
             ////			 $form->addText('discount_hash', _('Zľavový kupón (3%)'));
             //
             $form->addGroup('');
             $form->addText('login', _('Email'))->addRule(NForm::FILLED, 'Email musí byť vyplnený')->addRule(NForm::EMAIL, 'Email nie je v správnom tvare');
             //
             //			 //obchodne + button
             //			 $form->addGroup();
             //
             $form->addTextarea('text', 'Poznámka k objednávke');
             ////			 $form->addCheckbox('need_available_to_48_hour', ' V prípade ak ste si objednali z ponuky "Tovar dostupný do 48 hod." prosím potvrdte, či chcete tovar dodať do 48 hod.');
             ////
             //			 $conf = $this->context->parameters;
             //
             //			 $form->addCheckbox('terms_and_conditions',
             //					 NHtml::el('span')
             //						->setHtml(_('Obchodné podmienky '))
             //							->add(
             //								NHtml::el('a')
             //									->href( $this->link(':Front:Article:default',array('id'=>$conf['CONDITIONS_CMS_ID'], 'id_menu_item'=>$conf['CONDITIONS_CMS_PAGE_ID']) ))
             //											->setHtml("("._('viac').")")
             //							)
             //				)->addRule(NForm::FILLED, 'Je potrebné súhlasiť s obchodnými podmienkami.');
             $form->addSubmit('btn_user_form', _('Pokračovať'))->getControlPrototype()->class = 'classic-btn border-radius-2';
             //ak je prihlaseny vyplnia sa polia
             if ($this->user->isLoggedIn()) {
                 $form->setDefaults($this->user->getIdentity()->data);
             }
             //ak uz zadal informacie
             $order_info = NEnvironment::getSession('user_order_info');
             if (isset($order_info['values']) and !empty($order_info['values'])) {
                 $form->setDefaults($order_info['values']);
             }
             $form->onSuccess[] = array($this, 'saveUserInfo');
             return $form;
             break;
         default:
             return parent::createComponent($name);
             break;
     }
 }
 function createComponent($name)
 {
     switch ($name) {
         default:
             return parent::createComponent($name);
             break;
     }
 }
 protected function createComponent($name)
 {
     switch ($name) {
         case 'lostPasswordForm':
             $form = new NAppForm();
             $form->addText('login', 'Prihlasovacie meno/Email')->addRule(NFORM::FILLED, 'Prihlasovacie meno musí byť vyplnené.');
             //				$form->addText('email', 'Emailová adresa')
             //					->addRule(NFORM::EMAIL,'Emailová adresa nie je v správnom tvare.');
             //
             $form->addSubmit('btn_submit_lost_password', 'Odoslať')->getControlPrototype()->class = 'classic-btn border-radius-2';
             $form->onSuccess[] = array($this, 'sendLostPassword');
             return $form;
             break;
         case 'registrationForm':
             $form = $this->createComponent('userBaseForm');
             $form['password']->addRule(NForm::FILLED, _('Heslo musí byť vyplnené'))->addRule(NForm::MIN_LENGTH, _('Minimálny počet znakov pre heslo je %s'), 5);
             $form->addGroup('');
             $form->addSubmit('btn_user_form', _('Registrovať'))->getControlPrototype()->class = 'classic-btn border-radius-2';
             $form->onSuccess[] = array($this, 'saveRegistration');
             return $form;
             break;
         case 'profilForm':
             $form = $this->createComponent('userBaseForm');
             //				$form['btn_user_form']->setValues('Uložiť');
             $form->setDefaults($this->user->getIdentity()->data);
             //				print_r($this->user->getIdentity()->data);
             $form->addGroup();
             $form->addSubmit('btn_user_form', _('Uložiť'))->getControlPrototype()->class = 'classic-btn border-radius-2';
             $form->onSuccess[] = array($this, 'saveProfil');
             return $form;
             break;
         default:
             return parent::createComponent($name);
             break;
     }
 }