App\Source\ModelFieldBuilder\RadioField::__toString PHP Method

__toString() public method

public __toString ( )
    public function __toString()
    {
        if (!$this->visible || $this->name == 'default') {
            return '';
        }
        $options = '';
        foreach ($this->values as $value => $name) {
            $str = '<div class="radio"><label>';
            $str .= sprintf('<input type="%s" value="%s" name="%s" #> %s', $this->type, $value, $this->name, $name);
            if ($this->value !== null && (string) $this->value == (string) $value) {
                $str = str_replace("#", "# checked=\"checked\"", $str);
            }
            if ($this->value === null && (string) $this->default == (string) $value) {
                $str = str_replace("#", "# checked=\"checked\"", $str);
            }
            $options .= $str . '</label></div>';
        }
        $this->className = str_replace("form-control", "", $this->className);
        return $this->toString($options);
    }