Exemplo n.º 1
0
 public function testLabels()
 {
     $this->specify("Form::getLabel and Form::label do not return the correct values", function () {
         $form = new Form();
         $form->add(new Text("name"));
         $telephone = new Text("telephone");
         $telephone->setLabel("The Telephone");
         $form->add($telephone);
         expect($form->getLabel("name"))->equals("name");
         expect($form->getLabel("telephone"))->equals("The Telephone");
         expect($form->label("name"))->equals("<label for=\"name\">name</label>");
         expect($form->label("telephone"))->equals("<label for=\"telephone\">The Telephone</label>");
         // https://github.com/phalcon/cphalcon/issues/1029
         expect($form->label("name", ["class" => "form-control"]))->equals("<label for=\"name\" class=\"form-control\">name</label>");
         expect($form->label("telephone", ["class" => "form-control"]))->equals("<label for=\"telephone\" class=\"form-control\">The Telephone</label>");
     });
 }
Exemplo n.º 2
0
 /**
  * Generate the label of a element added to the form including HTML
  *
  * @param string $name
  * @param array $attributes
  * @return string
  */
 public function label($name, array $attributes = NULL)
 {
     if ($this->_autoGenerateTranslateHelpLabel && $this->_formName) {
         if (!isset($attributes['data-toggle'])) {
             $attributes['data-toggle'] = 'tooltip';
         }
         if (!isset($attributes['data-placement'])) {
             $attributes['data-placement'] = 'top';
         }
         $attributes['title'] = __($this->_formName . '_' . $name . '_desc');
         return parent::label($name, $attributes);
     } else {
         return parent::label($name, $attributes);
     }
 }
Exemplo n.º 3
0
 public function testIssues1029()
 {
     $form = new Form();
     $form->add(new Text("name"));
     $telephone = new Text("telephone");
     $telephone->setLabel("The Telephone");
     $form->add($telephone);
     $this->assertEquals($form->label('name', array('class' => 'form-control')), '<label for="name" class="form-control">name</label>');
     $this->assertEquals($form->label('telephone', array('class' => 'form-control')), '<label for="telephone" class="form-control">The Telephone</label>');
 }
Exemplo n.º 4
0
 public function testFormLabels()
 {
     $form = new Form();
     $form->add(new Text("name"));
     $telephone = new Text("telephone");
     $telephone->setLabel("The Telephone");
     $form->add($telephone);
     $this->assertEquals($form->getLabel('name'), 'name');
     $this->assertEquals($form->getLabel('telephone'), 'The Telephone');
     $this->assertEquals($form->label('name'), '<label for="name">name</label>');
     $this->assertEquals($form->label('telephone'), '<label for="telephone">The Telephone</label>');
 }