HtmlObject\Traits\Tag::open PHP Method

open() public method

Opens the Tag.
public open ( ) : string | null
return string | null
    public function open()
    {
        $this->isOpened = true;
        // If self closing, put value as attribute
        foreach ($this->injectProperties() as $attribute => $property) {
            if (!$this->isSelfClosing && $attribute == 'value') {
                continue;
            }
            if (is_null($property) && !is_empty($property)) {
                continue;
            }
            $this->attributes[$attribute] = $property;
        }
        // Invisible tags
        if (!$this->element) {
            return;
        }
        return '<' . $this->element . Helpers::parseAttributes($this->attributes) . $this->getTagCloser();
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Opens a group
  *
  * @return string Opening tag
  */
 public function open()
 {
     if ($this->getErrors()) {
         $this->state($this->app['former.framework']->errorState());
     }
     // Retrieve state and append it to classes
     if ($this->state) {
         $this->addClass($this->state);
     }
     // Required state
     if ($this->app->bound('former.field') and $this->app['former.field']->isRequired()) {
         $this->addClass($this->app['former']->getOption('required_class'));
     }
     return parent::open();
 }