Exemple #1
0
 public function __invoke(Form $form)
 {
     $this->form = $form;
     $this->children = $form->get_ordered_children();
     $this->contents = null;
     return $this->render_inner_html();
 }
Exemple #2
0
 public function offsetSet($attribute, $value)
 {
     if ($attribute == self::VALUES) {
         $this->hiddens[Operation::KEY] = empty($value['id']) ? null : $value['id'];
     }
     parent::offsetSet($attribute, $value);
 }
Exemple #3
0
 public function render()
 {
     $password_recovery_link = $this[self::PASSWORD_RECOVERY_LINK];
     if ($password_recovery_link) {
         $this->lost_password['href'] = $password_recovery_link;
     }
     return parent::render();
 }
Exemple #4
0
 public function __construct(array $attributes = array())
 {
     global $core;
     $user = $core->user;
     $is_member = !$user->is_guest;
     $values = array();
     if ($is_member) {
         $values[Comment::AUTHOR] = $user->name;
         $values[Comment::AUTHOR_EMAIL] = $user->email;
     }
     parent::__construct(\ICanBoogie\array_merge_recursive($attributes, array(Form::RENDERER => 'Simple', Form::VALUES => $values, Form::HIDDENS => array(Operation::DESTINATION => 'comments', Operation::NAME => 'save'), Element::CHILDREN => array(Comment::AUTHOR => new Text(array(Element::LABEL => 'Name', Element::REQUIRED => true)), Comment::AUTHOR_EMAIL => new Text(array(Element::LABEL => 'E-mail', Element::REQUIRED => true, Element::VALIDATOR => array('Brickrouge\\Form::validate_email'))), Comment::AUTHOR_URL => new Text(array(Element::LABEL => 'Website')), Comment::CONTENTS => new Element('textarea', array(Element::REQUIRED => true, Element::LABEL_MISSING => 'Message', 'class' => 'span6', 'rows' => 8)), Comment::NOTIFY => new Element(Element::TYPE_RADIO_GROUP, array(Form::LABEL => "Shouhaitez-vous être informé d'une réponse à votre message ?", Element::OPTIONS => array('yes' => "Bien sûr !", 'author' => "Seulement si c'est l'auteur du billet qui répond.", 'no' => "Pas la peine, je viens tous les jours."), Element::DEFAULT_VALUE => 'no', 'class' => 'inputs-list'))), Element::WIDGET_CONSTRUCTOR => 'SubmitComment', 'action' => '#view-comments-submit', 'class' => 'widget-submit-comment')), 'div');
 }
 public function __construct($tags, $dummy = null)
 {
     parent::__construct(\ICanBoogie\array_merge_recursive($tags, array(self::RENDERER => 'Simple', Element::CHILDREN => array('email' => new Text(array(Element::LABEL => 'Votre e-mail', Element::REQUIRED => true, Element::VALIDATOR => array('Brickrouge\\Form::validate_email'))), 'message' => new Element('textarea', array(self::LABEL_MISSING => 'Message', Element::REQUIRED => true))))));
 }
Exemple #6
0
 /**
  * Validates the specified value.
  *
  * This function uses the validator defined using the {@link VALIDATOR} special attribute to
  * validate its value.
  *
  * @param $value
  * @param \ICanBoogie\Errors $errors
  *
  * @return boolean `true` if  the validation succeed, `false` otherwise.
  */
 public function validate($value, Errors $errors)
 {
     $validator = $this[self::VALIDATOR];
     $options = $this[self::VALIDATOR_OPTIONS];
     if ($validator) {
         if ($validator instanceof \Closure) {
             return $validator($errors, $this, $value);
         }
         list($callback, $params) = $validator + [1 => []];
         return call_user_func($callback, $errors, $this, $value, $params);
     }
     #
     # default validator
     #
     if (!$options) {
         return true;
     }
     switch ($this->type) {
         case self::TYPE_CHECKBOX_GROUP:
             if (isset($options['max-checked'])) {
                 $limit = $options['max-checked'];
                 if (count($value) > $limit) {
                     $errors[$this->name] = $this->t('Le nombre de choix possible pour le champ %name est limité à :limit', ['name' => Form::select_element_label($this), 'limit' => $limit]);
                     return false;
                 }
             }
             break;
     }
     return true;
 }
 public function __construct(array $attributes = array())
 {
     parent::__construct($attributes + array(Form::ACTIONS => new Button('Send', array('type' => 'submit', 'class' => 'btn-warning')), Form::RENDERER => 'Simple', Form::HIDDENS => array(Operation::DESTINATION => 'users.noncelogin', Operation::NAME => 'nonce-login-request'), Element::CHILDREN => array('email' => new Text(array(Form::LABEL => 'your_email', Element::REQUIRED => true))), Element::WIDGET_CONSTRUCTOR => 'NonceRequest', 'class' => 'widget-nonce-request', 'name' => 'users/nonce-request'));
 }
Exemple #8
0
 protected function render_inner_html()
 {
     return "ouic" . parent::render_inner_html();
 }
Exemple #9
0
 public function __construct(array $attributes = [])
 {
     parent::__construct($attributes + [Form::ACTIONS => [new Button("Sign in", ['class' => "btn-primary btn-lg btn-block", 'type' => 'submit'])], Form::HIDDENS => [Operation::DESTINATION => 'users', Operation::NAME => 'sign-in'], Element::CHILDREN => [new Element('h4', [Element::INNER_HTML => "Please sign in", 'class' => "form-signin-heading"]), 'username' => new Text([Element::REQUIRED => true, 'autofocus' => true, 'class' => 'form-control', 'placeholder' => 'User name']), 'password' => new Text([Element::REQUIRED => true, 'class' => 'form-control', 'placeholder' => 'Password', 'type' => 'password'])], 'class' => 'form-signin', 'name' => 'users/signin']);
 }
Exemple #10
0
 public function __construct(array $attributes = array())
 {
     parent::__construct(\ICanBoogie\array_merge_recursive($attributes, array(self::RENDERER => 'Simple', Element::CHILDREN => array('gender' => new Element(Element::TYPE_RADIO_GROUP, array(self::LABEL => 'Salutation', Element::OPTIONS => array('salutation.Misses', 'salutation.Mister'), Element::REQUIRED => true, 'class' => 'inline-inputs')), 'firstname' => new Text(array(self::LABEL => 'Firstname', Element::REQUIRED => true)), 'lastname' => new Text(array(self::LABEL => 'Lastname', Element::REQUIRED => true)), 'company' => new Text(array(self::LABEL => 'Company')), 'email' => new Text(array(self::LABEL => 'E-mail', Element::REQUIRED => true, Element::VALIDATOR => array('Brickrouge\\Form::validate_email'))), 'message' => new Element('textarea', array(self::LABEL => 'Your message', Element::REQUIRED => true))))), 'div');
 }
 public function __construct($tags, $dummy = null)
 {
     parent::__construct(\ICanBoogie\array_merge_recursive($tags, array(Element::CHILDREN => array('gender' => new Element(Element::TYPE_RADIO_GROUP, array(self::LABEL => 'Gender', Element::OPTIONS => array('salutation.misses', 'salutation.miss', 'salutation.mister'), Element::REQUIRED => true)), 'lastname' => new Text(array(self::LABEL => 'Lastname', Element::REQUIRED => true)), 'firstname' => new Text(array(self::LABEL => 'Firstname', Element::REQUIRED => true)), 'media' => new Text(array(self::LABEL => 'Média')), 'email' => new Text(array(self::LABEL => 'E-Mail', Element::REQUIRED => true, Element::VALIDATOR => array('Brickrouge\\Form::validate_email'))), 'subject' => new Text(array(self::LABEL => 'Subject', Element::REQUIRED => true)), 'message' => new Element('textarea', array(self::LABEL => 'Your message'))))));
 }
 public function __construct(array $attributes = [])
 {
     parent::__construct($attributes + [Form::HIDDENS => [Operation::DESTINATION => 'comments', Operation::NAME => 'submit', 'post_id' => empty($attributes[self::POST_ID]) ? null : $attributes[self::POST_ID]], Form::ACTIONS => [new Button("Submit", ['class' => 'btn-primary', 'type' => 'submit'])], Element::CHILDREN => ['mail' => new Text([Element::REQUIRED => true, Element::VALIDATOR => ['Brickrouge\\Form::validate_email'], 'class' => 'form-control', 'placeholder' => "Your email", 'type' => 'email']), 'username' => new Text([Element::REQUIRED => true, 'class' => 'form-control', 'placeholder' => "Your name", 'size' => 50]), 'content' => new Element('textarea', [Element::REQUIRED => true, 'class' => 'form-control', 'placeholder' => "Your comment", 'rows' => 3])], 'name' => 'comments/submit']);
 }
Exemple #13
0
 public function __construct(array $attributes = array())
 {
     parent::__construct($attributes + array(Form::ACTIONS => new Button("Continue", array('class' => 'btn btn-primary', 'type' => 'submit')), Form::RENDERER => 'Simple', 'method' => Request::METHOD_PATCH, 'class' => 'form-horizontal'));
 }