Example #1
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;
 }
 /**
  * getForm
  *
  * @return  Form
  */
 public function getForm()
 {
     return $this->fetch('login.form', function () {
         $form = new Form('registration');
         $form->defineFormFields(new RegistrationFieldDefinition());
         return $form;
     });
 }
Example #3
0
 /**
  * getForm
  *
  * @return  Form
  */
 public function getForm()
 {
     return $this->fetch('forgot.form', function () {
         $form = new Form();
         $form->defineFormFields(new ForgotFieldDefinition());
         return $form;
     });
 }
Example #4
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 #5
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();
 }
Example #6
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();
 }
 /**
  * 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;
     });
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
Example #10
0
 /**
  * getByDefine
  *
  * @param string $control
  *
  * @return  Form
  *
  * @covers  Windwalker\Form\Form::defineFormFields
  */
 protected function getByDefine($control = null)
 {
     $form = new Form($control);
     $form->defineFormFields(new StubFieldDefinition());
     return $form;
 }
Example #11
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;
 }