public function createComponent($name) { switch ($name) { case 'settingsForm': $form = new AppForm($this, $name); // basic $form->addGroup(__('Basic')); $form->addText('shopName', __('Shop name:'))->addRule(Form::FILLED, __('You have to entry shop name.')); $form->addText('shopSlogan', __('Shop slogan:'))->addRule(Form::FILLED, __('You have to entry shop slogan.')); $form->addText('shopEmail', __('Contact e-mail:'))->addRule(Form::FILLED, __('You have to entry contact e-mail.')); // address $form->addGroup(__('Shop address')); $form->addText('shopAddressCompany', __('Company:')); $form->addText('shopAddressName', __('Name:'))->addRule(Form::FILLED, __('You have to entry name.')); $form->addText('shopAddressStreet', __('Street:'))->addRule(Form::FILLED, __('You have to entry street.')); $form->addText('shopAddressCity', __('City:'))->addRule(Form::FILLED, __('You have to entry city.')); $form->addText('shopAddressPostcode', __('Post code:'))->addRule(Form::FILLED, __('You have to entry post code.')); // miscellaneous $form->addGroup(__('Miscellaneous')); $form->addText('metaKeywords', __('META keywords:'))->addRule(Form::FILLED, __('You have to entry META keywords.')); $form->addText('metaDescription', __('META description:'))->addRule(Form::FILLED, __('You have to entry META description.')); $form->addText('currency', __('Currency:'))->addRule(Form::FILLED, __('You have to entry currency.')); $form->addText('itemsPerPage', __('Items per page:'))->addRule(Form::FILLED, __('You have to entry items per page.'))->addRule(Form::FILLED, __('Items per page has to be a number.')); $themes = array(0 => __('–––')); foreach (new DirectoryIterator(Environment::expand('%themeDir%')) as $_) { if (!$_->isDot() && $_->isDir()) { $themes[$_->getFilename()] = $_->getFilename(); } } $form->addSelect('theme', __('Theme:'), $themes)->skipFirst(); $form['theme']->addRule(Form::FILLED, __('You have to select theme.')); // submit $form->setCurrentGroup(NULL); $form->addSubmit('ok', '✔ ' . __('Save')); $form->onSubmit[] = array($this, 'onSettingsFormSubmit'); break; case 'changeLoginForm': $form = new AppForm($this, $name); $form->addText('username', __('Username:'******'You have to entry username.')); $form->addPassword('old_password', __('Old password:'******'You have to entry old password.')); $form->addPassword('new_password', __('New password:'******'You have to entry new password.')); $form->addPassword('new_password_again', __('New password (again):'))->addRule(Form::FILLED, __('You have to entry new password again.'))->addRule(Form::EQUAL, __('New passwords have to match.'), $form['new_password']); $form->addSubmit('ok', '✔ ' . __('Change')); $form->onSubmit[] = array($this, 'onChangeLoginFormSubmit'); break; default: parent::createComponent($name); } }
/** * 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); } }