Contao\TextField::generate PHP Method

generate() public method

Generate the widget and return it as string
public generate ( ) : string
return string
    public function generate()
    {
        $strType = $this->hideInput ? 'password' : 'text';
        if (!$this->multiple) {
            // Hide the Punycode format (see #2750)
            if ($this->rgxp == 'url') {
                $this->varValue = \Idna::decode($this->varValue);
            } elseif ($this->rgxp == 'email' || $this->rgxp == 'friendly') {
                $this->varValue = \Idna::decodeEmail($this->varValue);
            }
            return sprintf('<input type="%s" name="%s" id="ctrl_%s" class="tl_text%s" value="%s"%s onfocus="Backend.getScrollOffset()">%s', $strType, $this->strName, $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', \StringUtil::specialchars($this->varValue), $this->getAttributes(), $this->wizard);
        }
        // Return if field size is missing
        if (!$this->size) {
            return '';
        }
        if (!is_array($this->varValue)) {
            $this->varValue = array($this->varValue);
        }
        $arrFields = array();
        for ($i = 0; $i < $this->size; $i++) {
            $arrFields[] = sprintf('<input type="%s" name="%s[]" id="ctrl_%s" class="tl_text_%s" value="%s"%s onfocus="Backend.getScrollOffset()">', $strType, $this->strName, $this->strId . '_' . $i, $this->size, \StringUtil::specialchars(@$this->varValue[$i]), $this->getAttributes());
        }
        return sprintf('<div id="ctrl_%s" class="tl_text_field%s">%s</div>%s', $this->strId, $this->strClass != '' ? ' ' . $this->strClass : '', implode(' ', $arrFields), $this->wizard);
    }