/**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $form->addField(new TextareaField('metadesc', 'Meta Description'))->set('class', 'form-control')->set('rows', 5);
     $form->addField(new CategoriesField('category', 'Categories'))->set('class', 'chosen-select form-control')->set('multiple', true)->setBlog($this->blog->id);
     $form->addField(new ListField('state', 'State'))->setOptions(array(new Option('Publish', 1), new Option('Unpublish', 0)))->set('class', 'form-control');
     $form->addField(new AuthorsField('author', 'Author'))->setOptions(array(new Option('- Select Author -', '0')))->set('class', 'form-control')->setBlog($this->blog->id);
 }
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $form->add('password', new PasswordField())->label('Password')->required();
     $form->add('password2', new PasswordField())->label('Verify Password')->required();
     $form->add('username', new HiddenField());
     $form->add('token', new HiddenField());
 }
Example #3
0
 /**
  * getForm
  *
  * @param array $data
  *
  * @return  Form
  */
 public function getForm($data = array())
 {
     $form = new Form('user');
     $form->defineFormFields(new ProfileDefinition());
     $form->bind($data);
     return $form;
 }
Example #4
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $langPrefix = WarderHelper::getPackage()->get('frontend.language.prefix', 'warder.');
     $form->add('password', new Field\PasswordField())->label(Translator::translate($langPrefix . 'user.field.password'))->set('placeholder', Translator::translate($langPrefix . 'user.field.password'));
     $form->add('password2', new Field\PasswordField())->label(Translator::translate($langPrefix . 'user.field.password.confirm'))->set('placeholder', Translator::translate($langPrefix . 'user.field.password.confirm'));
     $form->add('email', new Field\HiddenField());
     $form->add('token', new Field\HiddenField());
 }
Example #5
0
 /**
  * getForm
  *
  * @return  Form
  */
 public function getForm()
 {
     return $this->fetch('forgot.form', function () {
         $form = new Form();
         $form->defineFormFields(new ForgotFieldDefinition());
         return $form;
     });
 }
Example #6
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $loginName = WarderHelper::getLoginName();
     $langPrefix = WarderHelper::getPackage()->get('frontend.language.prefix', 'warder.');
     $form->add($loginName, new Field\TextField())->label(Translator::translate($langPrefix . 'user.field.' . $loginName));
     $form->add('password', new Field\PasswordField())->label(Translator::translate($langPrefix . 'user.field.password'));
     $form->add('remember', new Field\CheckboxField())->label(Translator::translate($langPrefix . 'user.field.remember'));
 }
 /**
  * getForm
  *
  * @return  Form
  */
 public function getForm()
 {
     return $this->fetch('login.form', function () {
         $form = new Form('registration');
         $form->defineFormFields(new RegistrationFieldDefinition());
         return $form;
     });
 }
Example #8
0
 /**
  * getForm
  *
  * @param array $data
  *
  * @return  Form
  */
 public function getForm($data = array())
 {
     $form = new Form('author');
     $form->defineFormFields(new AuthorDefinition());
     if ($data) {
         $form->bind($data);
     }
     return $form;
 }
Example #9
0
 /**
  * doExecute
  *
  * @return  string
  */
 protected function doExecute()
 {
     $view = new SettingsHtmlView($this->data);
     $form = new Form('blog');
     $form->defineFormFields(new BlogDefinition());
     $form->bind($view['blog']);
     $view['form'] = $form;
     $view['item'] = $view['blog'];
     return $view->setLayout('edit')->render();
 }
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $form->addField(new TextField('username', 'Username'))->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label')->disabled();
     $form->addField(new TextField('fullname', 'Full Name'))->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label')->required();
     $form->addField(new EmailField('email', 'Email'))->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label')->required();
     $form->addField(new TextareaField('description', 'Description'))->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label')->set('rows', 5);
     $form->addField(new TimezoneField('timezone', 'Timezone'), 'other')->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label')->required();
     $form->addField(new TextField('website', 'Website'))->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label');
     $form->addField(new TextField('website', 'Website'))->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label');
     $form->addField(new PasswordField('password', 'Password'))->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label')->set('autocomplete', 'off');
     $form->addField(new PasswordField('password2', 'Verify Password'))->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label')->set('autocomplete', 'off');
 }
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $form->addField(new TextField('name', 'Name'), 'author')->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label')->required();
     $form->addField(new TextareaField('description', 'Description'), 'author')->set('class', 'form-control')->set('rows', 5)->set('labelClass', 'col-sm-3 control-label');
     //		$form->addField(new ListField('admin', 'Is Admin'), 'author')
     //			->setOptions([
     //				new Option('Yes', 1),
     //				new Option('No', 0)
     //			])
     //			->set('class', 'form-control')
     //			->set('labelClass', 'col-sm-3 control-label');
     $form->addField(new HiddenField('uuid'), 'hidden');
 }
Example #12
0
 /**
  * doExecute
  *
  * @return  mixed
  */
 protected function doExecute()
 {
     $id = $this->input->get('id');
     $blog = $id ? (new DataMapper('blogs'))->findOne($id) : new Data();
     $blog->params = json_decode($blog->params);
     $view = new SettingsHtmlView($this->data);
     $form = new Form('blog');
     $form->defineFormFields(new BlogDefinition());
     $form->bind($blog);
     $view['form'] = $form;
     $view['item'] = $blog;
     return $view->setLayout('edit')->render();
 }
Example #13
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $form->addField(new TextField('alias', 'Blog Name'), 'basic')->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label')->required();
     // $form->addField(new TextField('domain'));
     $form->addField(new TextField('title', 'Blog Title'), 'basic')->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label')->required();
     $form->addField(new TextField('sub_title', 'Sub Title'), 'basic')->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label');
     $form->addField(new TextareaField('description', 'Description'), 'basic')->set('class', 'form-control')->set('rows', 5)->set('labelClass', 'col-sm-3 control-label');
     $form->addField(new TimezoneField('timezone', 'Timezone'), 'other')->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label')->set('default', 'UTC')->required();
     $form->addField(new TextField('disqus', 'Disqus Shortname'), 'other')->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label');
     $form->addField(new TextField('webmaster', 'Google Webmaster'), 'other')->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label');
     $form->addField(new TextField('analytics', 'Analytics'), 'other')->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label');
     $form->addField(new TextareaField('css', 'Custom CSS'), 'style', 'params')->set('class', 'form-control')->set('labelClass', 'col-sm-3 control-label');
 }
 /**
  * getForm
  *
  * @return  Form
  */
 public function getForm()
 {
     return $this->fetch('login.form', function () {
         $form = new Form('registration');
         $form->defineFormFields(new RegistrationFieldDefinition());
         foreach ($form as $field) {
             /** @var AbstractField $field */
             $field->set('controlClass', 'form-group');
             $field->set('class', 'form-control col-md-10');
             $field->set('labelClass', 'control-label col-md-2');
         }
         return $form;
     });
 }
Example #15
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     /*
      * This is batch form definition.
      * -----------------------------------------------
      * Every field is a table column.
      * For example, you can add a 'category_id' field to update item category.
      */
     $form->wrap(null, 'batch', function (Form $form) {
         // Language
         $form->add('language', new ListField())->label('Language')->set('class', 'col-md-12')->addOption(new Option('-- Select Language --', ''))->addOption(new Option('English', 'en-GB'))->addOption(new Option('Chinese Traditional', 'zh-TW'));
         // Author
         $form->add('created_by', new TextField())->label('Author');
     });
 }
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $form->addField(new TextField('username', 'Username', array('required' => true)));
     $form->addField(new PasswordField('password', 'Password', array('required' => true)));
     //
     //		$form->addField(
     //			new PasswordField(
     //				'password2',
     //				'Validate Password'
     //			)
     //		);
     //
     //		$form->addField(new TextField('email'))
     //			->label('Email')
     //			->setFilter(InputFilter::EMAIL)
     //			->setValidator(new EmailValidator)
     //			->required(true);
 }
Example #17
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     /*
      * Search Control
      * -------------------------------------------------
      * Add search fields as options, by default, model will search all columns.
      * If you hop that user can choose a field to search, change "display" to true.
      */
     $form->wrap(null, 'search', function (Form $form) {
         // Search Field
         $form->add('field', new ListField())->label(Translator::translate('phoenix.grid.search.field.label'))->set('display', false)->defaultValue('*')->addOption(new Option(Translator::translate('phoenix.core.all'), '*'))->addOption(new Option(Translator::translate('admin.notification.field.title'), 'notification.title'))->addOption(new Option(Translator::translate('admin.notification.field.alias'), 'notification.alias'));
         // Search Content
         $form->add('content', new TextField())->label(Translator::translate('phoenix.grid.search.label'))->set('placeholder', Translator::translate('phoenix.grid.search.label'));
     });
     /*
      * Filter Control
      * -------------------------------------------------
      * Add filter fields to this section.
      * Remember to add onchange event => this.form.submit(); or Phoenix.post();
      *
      * You can override filter actions in NotificationsModel::configureFilters()
      */
     $form->wrap(null, 'filter', function (Form $form) {
         // State
         $form->add('notification.state', new ListField())->label('State')->addOption(new Option('', ''))->addOption(new Option(Translator::translate('admin.notification.filter.state.select'), ''))->addOption(new Option(Translator::translate('phoenix.grid.state.published'), '1'))->addOption(new Option(Translator::translate('phoenix.grid.state.unpublished'), '0'))->set('onchange', 'this.form.submit()');
     });
 }
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $loginName = WarderHelper::getLoginName();
     $langPrefix = WarderHelper::getPackage()->get('frontend.language.prefix', 'warder.');
     $form->wrap('basic', null, function (Form $form) use($loginName, $langPrefix) {
         $form->add('name', new Field\TextField())->label(Translator::translate($langPrefix . 'user.field.name'))->required();
         if (strtolower($loginName) != 'email') {
             $form->add($loginName, new Field\TextField())->label(Translator::translate($langPrefix . 'user.field.' . $loginName))->setValidator(new UserExistsValidator($loginName))->required();
         }
         $form->add('email', new Field\EmailField())->label(Translator::translate($langPrefix . 'user.field.email'))->setValidator(new UserExistsValidator('email'))->required();
         $form->add('password', new Field\PasswordField())->label(Translator::translate($langPrefix . 'user.field.password'))->set('autocomplete', 'off');
         $form->add('password2', new Field\PasswordField())->label(Translator::translate($langPrefix . 'user.field.password.confirm'))->set('autocomplete', 'off');
         $form->add('avatar', new SingleImageDragField())->label('Avatar')->set('default_image', AvatarUploadHelper::getDefaultImage());
     });
 }
Example #19
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $form->addField(new TextField('id', 'ID'), 'a', null)->set('class', 'control-input')->setFilter(InputFilter::INTEGER);
     $form->addField(new TextField('username', 'Username'), 'a', 'u')->required()->set('class', 'control-input');
     $form->addField(new TextField('email', 'Email'), null, 'b')->required()->setValidator(new EmailValidator())->set('class', 'control-input');
     $form->addField(new PasswordField('password', 'Password'), 'pf', 'b')->setFilter(InputFilter::ALNUM);
     $form->addField(new TextField('address', 'Address'));
 }
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     // $faker = Factory::create();
     $form->addField(new TextField('username'))->label('Username')->required();
     $form->addField(new TextField('name'))->label('Name')->required();
     $form->addField(new PasswordField('password'))->label('Password')->required();
     $form->addField(new PasswordField('password2'))->set('default', 1234)->label('Valid Password');
     $form->addField(new EmailField('email'))->label('Email')->required();
 }
Example #21
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $loginName = $this->package->getLoginName();
     $form->wrap('basic', null, function (Form $form) use($loginName) {
         $form->add('name', new Field\TextField())->label(Translator::translate('warder.user.field.name'))->required();
         if (strtolower($loginName) != 'email') {
             $form->add($loginName, new Field\TextField())->label(Translator::translate('warder.user.field.' . $loginName))->required();
         }
         $form->add('email', new Field\EmailField())->label(Translator::translate('warder.user.field.email'))->required();
         $form->add('password', new Field\PasswordField())->label(Translator::translate('warder.user.field.password'))->set('autocomplete', 'off');
         $form->add('password2', new Field\PasswordField())->label(Translator::translate('warder.user.field.password.confirm'))->set('autocomplete', 'off');
     });
 }
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $form->wrap('forgot', null, function (Form $form) {
         $form->add('email', new TextField())->label('Email')->required();
     });
     $form->wrap('confirm', null, function (Form $form) {
         $form->add('username', new TextField())->label('Username')->required();
         $form->add('token', new TextField())->label('Token')->required();
     });
 }
 /**
  * getForm
  *
  * @param string|FieldDefinitionInterface $definition
  * @param string                          $control
  * @param bool|mixed                      $loadData
  *
  * @return Form
  */
 public function getForm($definition = null, $control = null, $loadData = false)
 {
     $form = new Form($control);
     if (is_string($definition)) {
         $definition = $this->getFieldDefinition($definition);
     }
     $form->defineFormFields($definition);
     if ($loadData === true) {
         $form->bind($this->getFormDefaultData());
     } elseif ($loadData) {
         $form->bind($loadData);
     }
     $renderer = $this->get('field.renderer', $this->formRenderer);
     if (class_exists($renderer)) {
         $form->setRenderer(new $renderer());
     }
     Ioc::getDispatcher()->triggerEvent('onModelAfterGetForm', array('form' => $form, 'model' => $this, 'control' => $control, 'definition' => $definition));
     return $form;
 }
Example #24
0
<?php

/**
 * Part of windwalker project. 
 *
 * @copyright  Copyright (C) 2014 - 2015 LYRASOFT. All rights reserved.
 * @license    GNU Lesser General Public License version 3 or later.
 */
include_once __DIR__ . '/../../../../vendor/autoload.php';
use Windwalker\Form\Field\ListField;
use Windwalker\Form\Field\TextareaField;
use Windwalker\Form\Form;
use Windwalker\Form\Field\TextField;
use Windwalker\Form\Field\PasswordField;
use Windwalker\Html\Option;
use Windwalker\Validator\Rule\EmailValidator;
$form = new Form();
$form->addField(new TextField('username', 'Username'));
$form->addField(new PasswordField('password', 'Password'));
$form->addField(new TextField('email', 'Email'));
$form->addField(new TextareaField('description', 'Description'));
echo $form->renderFields();
$field = new ListField('flower', 'Flower', array(new Option('', ''), new Option(1, 'Yes'), new Option(0, 'No')), array('class' => 'stub-flower'));
echo $field->render();
\Windwalker\Form\FilterHelper::addNamespace();
Example #25
0
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     // Basic fieldset
     $form->wrap('basic', null, function (Form $form) {
         // ID
         $form->add('id', new Field\HiddenField());
         // Title
         $form->add('title', new Field\TextField())->label(Translator::translate('admin.post.field.title'))->setFilter('trim')->required(true);
         // Alias
         $form->add('alias', new Field\TextField())->label(Translator::translate('admin.post.field.alias'));
         // Images
         $form->add('images', new Field\TextField())->label(Translator::translate('admin.post.field.images'));
         // URL
         $form->add('url', new Field\TextField())->label(Translator::translate('admin.post.field.url'))->setValidator(new Rule\UrlValidator())->set('class', 'validate-url');
         // Example: Post List
         $form->add('post_list', new PostListField())->label('List Example');
         // Example: Post Modal
         $form->add('post_modal', new PostModalField())->label('Modal Example');
     });
     // Text Fieldset
     $form->wrap('text', null, function (Form $form) {
         // Introtext
         $form->add('introtext', new Field\TextareaField())->label(Translator::translate('admin.post.field.introtext'))->set('rows', 10);
         // Fulltext
         $form->add('fulltext', new Field\TextareaField())->label(Translator::translate('admin.post.field.fulltext'))->set('rows', 10);
     });
     // Created fieldset
     $form->wrap('created', null, function (Form $form) {
         // State
         $form->add('state', new Field\RadioField())->label(Translator::translate('admin.post.field.state'))->set('class', 'btn-group')->set('default', 1)->addOption(new Option(Translator::translate('phoenix.grid.state.published'), '1'))->addOption(new Option(Translator::translate('phoenix.grid.state.unpublished'), '0'));
         // Version
         $form->add('version', new Field\TextField())->label(Translator::translate('admin.post.field.version'));
         // Created
         $form->add('created', new Phoenix\Field\CalendarField())->label(Translator::translate('admin.post.field.created'));
         // Modified
         $form->add('modified', new Phoenix\Field\CalendarField())->label(Translator::translate('admin.post.field.modified'));
         // Author
         $form->add('created_by', new Field\TextField())->label(Translator::translate('admin.post.field.author'));
         // Modified User
         $form->add('modified_by', new Field\TextField())->label(Translator::translate('admin.post.field.modifiedby'));
     });
 }
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $form->add('username', new TextField())->label('Username')->required();
     $form->add('password', new PasswordField())->label('Password')->required();
     $form->add('remember', new CheckboxField())->label('Remember me')->set('value', 1);
 }
Example #27
0
 /**
  * getForm
  *
  * @param array $data
  *
  * @return  Form
  */
 public function getForm($data = array())
 {
     $form = new Form();
     $form->defineFormFields(new PostDefinition(Blog::get()));
     $form->bind($data);
     if ($this['post.type'] == 'static') {
         $form->removeField('category');
     }
     return $form;
 }
Example #28
0
 /**
  * validate
  *
  * @param Data $data
  *
  * @return  boolean
  */
 protected function validate($data)
 {
     $form = new Form('blog');
     $form->defineFormFields(new BlogDefinition());
     $form->bind($data);
     if (!$form->validate()) {
         $errors = $form->getErrors();
         foreach ($errors as $error) {
             $this->addFlash($error->getMessage(), 'danger');
         }
         $this->setRedirect(Router::buildHttp('admin:blog', ['id' => $data->id ?: '']));
         return false;
     }
     // Check exists
     $conditions['alias'] = $data['alias'];
     if ($data->id) {
         $conditions[] = 'id != ' . $data->id;
     }
     $blog = (new DataMapper('blogs'))->findOne($conditions);
     if ($blog->notNull()) {
         $this->setRedirect(Router::buildHttp('admin:blog', ['id' => $data->id ?: '']), 'Blog Name has already been used', 'danger');
         return false;
     }
     return true;
 }
 /**
  * Define the form fields.
  *
  * @param Form $form The Windwalker form object.
  *
  * @return  void
  */
 public function define(Form $form)
 {
     $langPrefix = WarderHelper::getPackage()->get('frontend.language.prefix', 'warder.');
     $form->add('email', new Field\EmailField())->label(Translator::translate($langPrefix . '.user.field.email'))->set('placeholder', Translator::translate($langPrefix . '.user.field.email'))->required();
     $form->add('token', new Field\TextField())->label(Translator::translate($langPrefix . 'user.field.token'))->set('placeholder', Translator::translate($langPrefix . 'user.field.token'))->required();
 }
Example #30
0
 /**
  * Method to test addValidatorNamespace().
  *
  * @return void
  *
  * @covers Windwalker\Form\Form::addValidatorNamespace
  */
 public function testAddValidatorNamespace()
 {
     ValidatorHelper::reset();
     $form = new Form();
     $form->addValidatorNamespace('TestNS');
     $ns = ValidatorHelper::getNamespaces();
     $ns = iterator_to_array($ns);
     $this->assertEquals('TestNS', $ns[0]);
 }