示例#1
0
 public function testGetAttributes()
 {
     $htmlElement = new HtmlElement();
     $attributes = array('my' => 'foo', 'your' => 'bar', 'our' => 'baz');
     $htmlElement->setAttributes($attributes);
     $htmlElement->addAttribute('gimme', 'bacon');
     $this->assertEquals(array_merge($attributes, array('gimme' => 'bacon')), $htmlElement->getAttributes());
 }
 /**
  * Add attribute on element
  *
  * @param string $key
  * @param string $value
  *
  * @return $this
  */
 public function addAttribute($key, $value = null)
 {
     $this->element->addAttribute($key, $value);
     return $this;
 }
示例#3
0
 /**
  * @param Fieldset $fieldset
  * @param boolean  $groupActions
  *
  * @return HtmlElement
  */
 protected function renderFieldset(Fieldset $fieldset, $groupActions = false)
 {
     $fieldsetElement = new HtmlElement('fieldset');
     $id = $fieldset->getAttribute('id') ?: $fieldset->getName();
     $parent = $this->getElement();
     $fieldsetElement->addAttribute('id', $id);
     /**
      * This changes the scope of the current element,
      * so that the child elements (the ones that are about to be rendered),
      * will be set on the fieldset.
      * Then change it back again so that the fieldset will be added to the form.
      */
     $this->setElement($fieldsetElement)->renderElements($fieldset, $groupActions)->setElement($parent);
     return $fieldsetElement;
 }