Beispiel #1
0
 /**
  * Returns a \r8\HTML\Tag object that represents this instance
  *
  * @return \r8\HTML\Tag
  */
 public function getTag()
 {
     $tag = new \r8\HTML\Tag('input', null, array("type" => 'checkbox', "value" => 'on', "name" => $this->getName()));
     if ($this->getValue()) {
         $tag->setAttr("checked", "checked");
     }
     return $tag;
 }
Beispiel #2
0
 /**
  * Returns the an HTML tag that represents an individual option's radio button
  *
  * @param String|Integer $value The value of the option whose tag should be returned
  * @return \r8\HTML\Tag
  */
 public function getOptionRadioTag($value)
 {
     $value = \r8\indexVal($value);
     if (!$this->hasOption($value)) {
         throw new \r8\Exception\Index($value, "Option Value", "Option does not exist in field");
     }
     $tag = new \r8\HTML\Tag('input');
     $tag->importAttrs(array("name" => $this->getName(), "value" => $value, "type" => "radio", "id" => $this->getRadioOptionID($value)));
     if ($value == $this->getValue()) {
         $tag['checked'] = 'checked';
     }
     return $tag;
 }
Beispiel #3
0
 public function testRender()
 {
     $tag = new \r8\HTML\Tag("input");
     $this->assertSame("<input />", $tag->render());
     $tag->setTag("option");
     $this->assertSame("<option></option>", $tag->render());
     $tag->setAttr("value", "WA");
     $this->assertSame('<option value="WA"></option>', $tag->render());
     $tag->setAttr("selected");
     $this->assertSame('<option value="WA" selected></option>', $tag->render());
     $tag->setContent("Washington");
     $this->assertSame('<option value="WA" selected>Washington</option>', $tag->render());
 }