/** * 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; }
public function testClearAttrs() { $tag = new \r8\HTML\Tag("hr"); $this->assertSame(array(), $tag->getAttrs()); $tag->importAttrs(array("rel" => "nofollow", "class" => "link")); $this->assertSame(array("rel" => "nofollow", "class" => "link"), $tag->getAttrs()); $this->assertSame($tag, $tag->clearAttrs()); $this->assertSame(array(), $tag->getAttrs()); }