public function createComponent($name)
 {
     switch ($name) {
         case 'importForm':
             $form = new AppForm($this, $name);
             $form->addFile('file', __('File:'))->addRule(Form::FILLED, __('You have to entry file.'));
             $form->addText('provision', __('Provision (%):'))->addRule(Form::FILLED, __('You have to entry provison.'))->addRule(Form::NUMERIC, __('Provison has to be a number.'))->addRule(Form::RANGE, __('Provision has to be between 0 and 99.'), array(0, 99));
             $form->addCheckbox('update_only', __('only update existing products'));
             // availability_id
             $availabilities = array(0 => __('–––'));
             foreach (mapper::product_availabilities()->findAll() as $_) {
                 $availabilities[$_->getId()] = $_->getName();
             }
             $form->addSelect('availability_id', __('Default availability:'), $availabilities);
             $form->addSubmit('ok', '✔ ' . __('Import'));
             $form->setDefaults(array('provision' => 0, 'update_only' => TRUE));
             $form->onSubmit[] = array($this, 'onImportFormSubmit');
             break;
         case 'importManufacturersForm':
             $form = new AppForm($this, $name);
             $form->addFile('file', __('File:'))->addRule(Form::FILLED, __('You have to entry file.'));
             $form->addSubmit('ok', '✔ ' . __('Import'));
             $form->onSubmit[] = array($this, 'onImportManufacturersFormSubmit');
             break;
         default:
             parent::createComponent($name);
     }
 }
 /**
  * Example form factory
  * @return AppForm
  */
 protected function createComponentExampleForm()
 {
     $form = new AppForm();
     $form->addTextarea("text", "Text", 110, 20)->getControlPrototype()->class("texyla");
     $form->addSubmit("s", "Submit");
     return $form;
 }
 protected function createComponentDeleteForm()
 {
     $array = $this->fileModel->getAllFiles();
     $form = new AppForm();
     $form->addCheckBoxList('file', 'files:', $array['ids']);
     $form->addSubmit('delete', 'Smazat soubory')->onClick[] = array($this, 'deleteClicked');
     return $form;
 }
Example #4
0
 protected function createComponentLoginForm()
 {
     $form = new AppForm();
     $form->addText('userName', 'Uživatelské jméno:')->addRule(Form::FILLED, "Uživatelské jméno musí být zadáno");
     $form->addPassword('password', 'Heslo:')->addRule(Form::FILLED, "Heslo musí být zadáno");
     $form->addSubmit('ok', 'Přihlásit')->onClick[] = array($this, 'okClicked');
     return $form;
 }
Example #5
0
 function filterPageEditForm_create(AppForm $form)
 {
     if ($this->page->getParent()->getMeta('.category') == 'shop') {
         $form->addSelect("id_parent_change", "kategorie", PagesModel::getPagesByMeta('.category', 'shop')->getPairs(''));
         $form->addText("price", "cena");
         $form->addCheckbox("akce", "akce");
     }
     return $form;
 }
Example #6
0
 public function metaAddFormSubmitted(AppForm $form)
 {
     $this->page->addMeta($form->values['key'], $form->values['value']);
     $this->presenter->flashMessage('Nastavení přidáno');
     //$this->invalidateControl('editpage_metalist');
     $form->setValues(array(), TRUE);
     $this->invalidateControl();
     if (!$this->presenter->isAjax()) {
         $this->redirect('this#toc-meta');
     }
 }
 protected function createComponentFormGraphsSettings($name)
 {
     $form = new AppForm($this, $name);
     // construct form fields by first patient
     $fields = Storage::getInstance()->getStoredFields();
     foreach ($fields as $field => $props) {
         $form->addCheckbox($field, $field);
     }
     $form->addSubmit('save', 'Uložiť');
     $form->onSubmit[] = array($this, 'SubmittedGraphsSettings');
     return $form;
 }
Example #8
0
 public function redirectEditFormSubmitted(AppForm $form)
 {
     $values = $form->values;
     RedirectModel::replace($values);
     $this->template->redirects = RedirectModel::getAll();
     $this->flashMessage('Přesměrování přidáno/upraveno');
     $this->invalidateControl('redirecttable');
     $form->setValues(array(), TRUE);
     if (!$this->isAjax()) {
         $this->redirect('this');
     }
 }
Example #9
0
 public function editFormSubmitted(AppForm $form)
 {
     $values = $form->values;
     TranslationsModel::replace($values);
     $this->template->translations = TranslationsModel::getAll();
     $this->flashMessage('Překlad přidán/upraven');
     $this->invalidateControl('translationstable');
     $form->setValues(array(), TRUE);
     if (!$this->isAjax()) {
         $this->redirect('this');
     }
 }
Example #10
0
 function filterPageEditForm_create(AppForm $form)
 {
     foreach ($this->fields as $k => $v) {
         $label = is_array($v) && isset($v['label']) ? $v['label'] : $k;
         if (isset($v['type']) and $v['type'] == "textarea") {
             $form->addTextarea("fields_{$k}", $label);
         } elseif (isset($v['type']) and $v['type'] == "checkbox") {
             $form->addCheckbox("fields_{$k}", $label);
         } else {
             $form->addText("fields_{$k}", $label);
         }
     }
     return $form;
 }
Example #11
0
 public function createComponent($name)
 {
     switch ($name) {
         case 'loginForm':
             $form = new AppForm($this, $name);
             $form->addText('username', __('Username:'******'password', __('Password:'******'ok', __('Login'));
             $form->onSubmit[] = array($this, 'onLoginFormSubmit');
             break;
         default:
             return parent::createComponent($name);
     }
 }
Example #12
0
 public function __construct($parent = null, $name = null)
 {
     parent::__construct($parent, $name);
     $this->addText('query', 'Query');
     $this->addSubmit('btnSubmit', 'Search');
     $this->onSubmit[] = array($this, 'handleSubmit');
 }
Example #13
0
 public function beforeRender()
 {
     $this->attributes->action = Router::uri('blogSearch', array('q' => ''));
     if (!empty($this->controller->params['q'])) {
         $this->q->value($this->controller->params['q']);
     }
     return parent::beforeRender();
 }
Example #14
0
 public function __construct(IComponentContainer $parent = null, $name = null)
 {
     parent::__construct($parent, $name);
     $script = new LiveClientScript($this);
     $this->setTranslator(new Translator(Environment::getApplication()->getPresenter()->lang));
     $this->getRenderer()->setClientScript($script);
     $renderer = $this->getRenderer();
     $renderer->wrappers['label']['suffix'] = ':';
 }
Example #15
0
 public function __construct()
 {
     parent::__construct();
     $this->lang = Environment::getApplication()->getPresenter()->lang;
     $this->addText('email', 'email')->addRule(Form::FILLED, 'Please, fill in the email')->addRule(Form::EMAIL, 'E-mail is not valid');
     $this->addSubmit('submit', 'subscribe the newsletter');
     $this->onSuccess[] = callback($this, 'submitted');
     $this->setTranslator(new TranslationsModel($this->lang));
 }
Example #16
0
 public function __construct(IComponentContainer $parent = null, $name = null)
 {
     parent::__construct($parent, $name);
     $this->addProtection();
     $script = new LiveClientScript($this);
     $this->setTranslator(new Translator(Environment::getApplication()->getPresenter()->lang));
     $this->getRenderer()->setClientScript($script);
     $this->getElementPrototype()->class = 'ajax';
 }
Example #17
0
 public function beforeRender()
 {
     // add optional to all non mandatory fields
     foreach ($this->fieldset->children() as $FormField) {
         if ($FormField instanceof FormField && !in_array($FormField->type, array('checkbox', 'submit')) && !$FormField->mandatory) {
             $FormField->label .= ' ' . __('(optional)');
         }
     }
     return parent::beforeRender();
 }
Example #18
0
 protected function createComponentFormPatientProperties($name)
 {
     $form = new AppForm($this, $name);
     // construct form fields by first patient
     $fields = Storage::getInstance()->getStoredFields();
     foreach ($fields as $field => $props) {
         $form->addText($field, $field)->addRule(Form::FILLED, 'Nesmie byt prazdne!');
     }
     $form->addSubmit('save', 'Uložiť');
     return $form;
 }
Example #19
0
 public function loginFormSubmitted(AppForm $form)
 {
     try {
         $values = $form->values;
         //if ($values['remember']) {
         $this->user->setExpiration('+ 1 month', FALSE);
         //also in config.neon#session
         //} else {
         //	$this->user->setExpiration(0, TRUE);
         //}
         //TODO expiration(0) breaks uploadify
         $this->user->login($values['username'], $values['password']);
         if (isset($values['backlink'])) {
             $this->application->restoreRequest($values['backlink']);
         }
         $this->redirect(":Admin:Admin:");
     } catch (AuthenticationException $e) {
         $form->addError($e->getMessage());
     }
 }
Example #20
0
 /**
  * Login form component factory.
  * @return mixed
  */
 protected function createComponentLoginForm()
 {
     $form = new AppForm();
     $form->addText('username', 'Username:'******'Please provide an username.');
     $form->addPassword('password', 'Password:'******'Please provide a password.');
     $form->addSubmit('login', 'Login');
     $form->addProtection('Please submit this form again (security token has expired).');
     /**/
     $form->onSubmit[] = array($this, 'loginFormSubmitted');
     /**/
     /* PHP 5.3
     		$that = $this;
     		$form->onSubmit[] = function($form) use ($that) {
     			try {
     				$user = Environment::getUser();
     				$user->authenticate($form['username']->getValue(), $form['password']->getValue());
     				$that->getApplication()->restoreRequest($that->backlink);
     				$that->redirect('Dashboard:');
     
     			} catch (AuthenticationException $e) {
     				$form->addError($e->getMessage());
     			}
     		};*/
     return $form;
 }
Example #21
0
 public function createComponent($name)
 {
     switch ($name) {
         case 'searchForm':
             $form = new AppForm($this, $name);
             $form->addText('q', __('Query:'));
             $form['q']->getControlPrototype()->onclick('if (this.value === "' . __('Input search keywords') . '") {
                     this._default = this.value;
                     this.value = "";
                 }');
             $form['q']->getControlPrototype()->onblur('if (this.value === "" && this._default !== undefined) {
                     this.value = this._default;
                 }');
             $form->setAction($this->link('Search:default'));
             $form->setMethod('get');
             if (isset(Environment::getSession(SESSION_SEARCH_NS)->last)) {
                 $form->setDefaults(array('q' => Environment::getSession(SESSION_SEARCH_NS)->last));
             } else {
                 $form->setDefaults(array('q' => __('Input search keywords')));
             }
             break;
         default:
             return parent::createComponent($name);
     }
 }
Example #22
0
 protected function attached($presenter)
 {
     parent::attached($presenter);
     if (!$this->isSubmitted()) {
         $row = dibi::fetch("SELECT * FROM users WHERE username = %s", $presenter->user->id);
         $row['tags'] = $row['tags'];
         $row['projects'] = array_map(function ($a) {
             return trim($a, '()');
         }, explode(",", $row['projects']));
         if ($row) {
             $this->setValues($row);
         }
     }
 }
 /**
  * Login form component factory.
  * @return mixed
  */
 protected function createComponentLoginForm()
 {
     $form = new AppForm();
     $form->addText('username', 'Username:'******'Please provide a username.');
     $form->addPassword('password', 'Password:'******'Please provide a password.');
     $form->addCheckbox('remember', 'Remember me on this computer');
     $form->addSubmit('login', 'Login');
     $form->onSubmit[] = callback($this, 'loginFormSubmitted');
     return $form;
 }
Example #24
0
 public function createComponentContactForm()
 {
     $form = new AppForm();
     $form->addText("name", "Jméno");
     $form->addText("email", "E-mail")->setRequired('Vyplňte, prosím, správně svůj email.')->addRule(Form::EMAIL, 'Vyplňte, prosím, správně svůj email.');
     $form->addTextArea("text", "Zpráva")->setRequired('Vyplňte, prosím, svou zprávu.');
     $form->addSubmit("submit1", "Odeslat");
     //$form->addProtection(); //sends cookie ... wtf?
     $form->onSuccess[] = callback($this, 'contactFormSubmitted');
     return $form;
 }
Example #25
0
 protected function createComponentHomeForm($name)
 {
     $form = new AppForm();
     $form->addTextArea('text', 'Text')->addRule(Form::FILLED, "Bez textu zůstane úvodní strana prázdná")->getControlPrototype()->style = 'width: 685px; height: 370px';
     $form->addHidden('id');
     $dataSource = dibi::query('SELECT id, text FROM [options] WHERE [name]=%s', 'home')->fetch();
     if ($dataSource != null) {
         $form->setDefaults($dataSource);
     }
     $form->addSubmit('ok', 'Uložit')->onClick[] = array($this, 'saveClicked');
     return $form;
 }
 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);
     }
 }
Example #27
0
 public function startUp()
 {
     $this->config = array(array('type' => 'email', 'placeholder' => __('E-Mail'), 'label' => false), array('type' => 'password', 'label' => false, 'placeholder' => __('Passwort')), array('type' => 'submit', 'value' => __('anmelden')));
     return parent::startUp();
 }
 public function deleteOnFormSubmitted(AppForm $form)
 {
     if ($form['delete']->isSubmittedBy()) {
         try {
             $id = $this->getParam('id');
             dibi::query('DELETE FROM [' . TABLE_ACL . '] WHERE id=%i;', $id);
             $this->flashMessage('The access has been deleted.', 'ok');
             if (ACL_CACHING) {
                 unset($this->cache['gui_acl']);
                 // invalidate cache
             }
             $this->redirect('Permission:');
         } catch (Exception $e) {
             $form->addError('The access has not been deleted.');
             throw $e;
         }
     } else {
         $this->redirect('Permission:');
     }
 }
Example #29
0
 /**
  * Component factory.
  * @see Nette/ComponentContainer#createComponent()
  */
 protected function createComponentForm($name)
 {
     // NOTE: signal-submit on form disregard component's state
     //		because form is created directly by Presenter in signal handling phase
     //		and this principle is used to detect submit signal
     if (!$this->wasRendered) {
         $this->receivedSignal = 'submit';
     }
     $form = new AppForm($this, $name);
     $form->setTranslator($this->getTranslator());
     FormControl::$idMask = 'frm-datagrid-' . $this->getUniqueId() . '-%s-%s';
     $form->onSubmit[] = array($this, 'formSubmitHandler');
     $form->addSubmit('resetSubmit', 'Reset state');
     $form->addSubmit('filterSubmit', 'Apply filters');
     $form->addSelect('operations', 'Selected:', $this->operations);
     $form->addSubmit('operationSubmit', 'Send')->onClick = $this->onOperationSubmit;
     // page input
     $form->addText('page', 'Page', 1);
     $form['page']->setDefaultValue($this->page);
     $form->addSubmit('pageSubmit', 'Change page');
     // items per page selector
     $form->addSelect('items', 'Items per page', array_combine($this->displayedItems, $this->displayedItems));
     $form['items']->setDefaultValue($this->itemsPerPage);
     $form->addSubmit('itemsSubmit', 'Change');
     // generate filters FormControls
     if ($this->hasFilters()) {
         $defaults = array();
         $sub = $form->addContainer('filters');
         foreach ($this->getFilters() as $filter) {
             $sub->addComponent($filter->getFormControl(), $filter->getName());
             // NOTE: must be setted after is FormControl conntected to the form
             $defaults[$filter->getName()] = $filter->value;
         }
         $sub->setDefaults($defaults);
     }
     // checker
     if ($this->hasOperations()) {
         $sub = $form->addContainer('checker');
         if ($this->isSignalReceiver('submit')) {
             // NOTE: important!
             $ds = clone $this->dataSource;
             $this->filterItems();
         }
         foreach ($this->getRows() as $row) {
             $sub->addCheckbox($row[$this->keyName], $row[$this->keyName]);
         }
         if (isset($ds)) {
             $this->dataSource = $ds;
         }
     }
     $renderer = $form->getRenderer();
     $renderer->wrappers['controls']['container'] = NULL;
     $renderer->wrappers['label']['container'] = NULL;
     $renderer->wrappers['control']['container'] = NULL;
     $form->setRenderer($renderer);
     return;
 }
 public function createComponent($name)
 {
     switch ($name) {
         case 'pageAddForm':
         case 'pageEditForm':
             if (!isset($prefix_len)) {
                 $prefix_len = strlen('page');
             }
         case 'actualityAddFrom':
         case 'actualityEditForm':
             if (!isset($prefix_len)) {
                 $prefix_len = strlen('actuality');
             }
         case 'manufacturerAddForm':
         case 'manufacturerEditForm':
             if (!isset($prefix_len)) {
                 $prefix_len = strlen('manufacturer');
             }
         case 'categoryAddForm':
         case 'categoryEditForm':
             if (!isset($prefix_len)) {
                 $prefix_len = strlen('category');
             }
         case 'productAddForm':
         case 'productEditForm':
             if (!isset($prefix_len)) {
                 $prefix_len = strlen('product');
             }
             // form itself
             $action = substr($name, $prefix_len);
             $action = substr($action, 0, strlen($action) - 4);
             // instantiate
             $form = new AppForm($this, $name);
             // name
             $form->addText('name', __('Name:'))->addRule(Form::FILLED, __('You have to entry name.'));
             // edit or add?
             if (substr($name, strlen($name) - 8) !== 'EditForm') {
                 // add
                 $form->addText('nice_name', __('Name in URL:'))->addRule(Form::FILLED, __('You have to entry URL name.'));
             } else {
                 // edit
                 $form->addHidden('nice_name');
                 if (strncmp($name, 'manufacturer', 12) === 0 || strncmp($name, 'product', 7) === 0) {
                     $form->addHidden('id');
                 }
             }
             // is category?
             if (strncmp($name, 'category', 8) === 0) {
                 $form->addHidden('id');
             }
             // metas
             $form->addText('meta_keywords', __('META keywords:'));
             $form->addText('meta_description', __('META description:'));
             // description or content?
             if (strncmp($name, 'manufacturer', 12) === 0 || strncmp($name, 'category', 8) === 0) {
                 $form->addTextarea('content', __('Description:'));
             } else {
                 $form->addTextarea('content', __('Content:'));
             }
             // is product?
             if (strncmp($name, 'product', 7) === 0) {
                 // category
                 $categories = array(0 => __('–––'));
                 foreach (mapper::categories()->findAll() as $_) {
                     list($depth, $category) = $_;
                     $categories[$category->getId()] = str_repeat('–', $depth) . ' ' . $category->getName();
                 }
                 $form->addSelect('category_id', __('Category:'), $categories)->skipFirst();
                 // manufacturer
                 $manufacturers = array(0 => __('–––'));
                 foreach (mapper::manufacturers()->findAll() as $manufacturer) {
                     $manufacturers[$manufacturer->getId()] = $manufacturer->getName();
                 }
                 $form->addSelect('manufacturer_id', __('Manufacturer:'), $manufacturers)->skipFirst();
                 // availability
                 $availabilities = array(0 => __('–––'));
                 foreach (mapper::product_availabilities()->findAll() as $_) {
                     $availabilities[$_->getId()] = $_->getName();
                 }
                 $form->addSelect('availability_id', __('Availability:'), $availabilities)->skipFirst();
                 // code
                 $form->addText('code', __('Code:'));
                 // price
                 $form->addText('price', __('Price:'))->addRule(Form::NUMERIC, __('Price has to be a number.'));
             }
             // picture
             $pictures = array(0 => __('–––'));
             foreach (mapper::pictures()->findAll() as $_) {
                 $pictures[$_->getId()] = self::remove_ext($_->getFile());
             }
             $form->addSelect('picture_id', __('Picture:'), $pictures);
             // submit
             $form->addSubmit('ok', '✔ ' . __($action));
             $form->onSubmit[] = array($this, 'on' . ucfirst(substr($name, 0, strlen($name) - 4)) . 'Submit');
             break;
         case 'categoriesForm':
             $form = new AppForm($this, $name);
             $items = array(0 => __('–––'));
             foreach (mapper::categories()->findAll() as $_) {
                 list($depth, $category) = $_;
                 $items[$category->getId()] = str_repeat('–', $depth) . ' ' . $category->getName();
             }
             $form->addSelect('id', __('Category:'), $items)->skipFirst();
             $form->addSubmit('edit', '✎ ' . __('Edit'))->onClick[] = array($this, 'onCategoriesFormEdit');
             $form->addSubmit('add', '⊕ ' . __('Add subcategory'))->onClick[] = array($this, 'onCategoriesFormAdd');
             $form->addSubmit('delete', '⊗ ' . __('Delete'))->onClick[] = array($this, 'onCategoriesFormDelete');
             break;
         case 'newPictureForm':
             $form = new AppForm($this, $name);
             $form->addFile('file', __('File:'));
             $form->addText('rename', __('Rename to:'));
             $form->addText('description', __('Description:'));
             $form->addSubmit('ok', '➦ ' . __('Upload'));
             $form->onSubmit[] = array($this, 'onNewPictureSubmit');
             break;
         case 'availabilitiesForm':
             $form = new AppForm($this, $name);
             $availabilities = array(0 => __('–––'));
             foreach (mapper::product_availabilities()->findAll() as $_) {
                 $availabilities[$_->getId()] = $_->getName();
             }
             $form->addSelect('id', __('Availability:'), $availabilities)->skipFirst();
             $form['id']->addRule(Form::FILLED, __('You have to choose availability.'));
             $form->addSubmit('edit', '✎ ' . __('Edit'))->onClick[] = array($this, 'onAvailabilitiesFormEdit');
             $form->addSubmit('delete', '⊗ ' . __('Delete'))->onClick[] = array($this, 'onAvailabilitiesFormDelete');
             break;
         case 'availabilityAddForm':
         case 'availabilityEditForm':
             if (!isset($prefix_len)) {
                 $prefix_len = strlen('availability');
             }
             $action = substr($name, $prefix_len);
             $action = substr($action, 0, strlen($action) - 4);
             $form = new AppForm($this, $name);
             if (substr($name, strlen($name) - 8) === 'EditForm') {
                 $form->addHidden('id');
             }
             $form->addText('name', __('Name:'));
             $form->addSubmit('ok', '✔ ' . __($action));
             $form->onSubmit[] = array($this, 'on' . ucfirst(substr($name, 0, strlen($name) - 4)) . 'Submit');
             break;
         case 'titlePageForm':
             $form = new AppForm($this, $name);
             $form->addTextarea('content', __('Content:'))->addRule(Form::FILLED, __('You have to entry content.'));
             $form->addSubmit('save', '✔ ' . __('Save'));
             $form->onSubmit[] = array($this, 'onTitlePageFormSubmit');
             $form->setDefaults(array('content' => require_once Environment::expand('%titlePageFile%')));
             break;
         default:
             parent::createComponent($name);
     }
 }