FOF30\Form\Field\Model::getRepeatable PHP Method

getRepeatable() public method

Get the rendering of this field type for a repeatable (grid) display, e.g. in a view listing many item (typically a "browse" task)
Since: 2.0
public getRepeatable ( ) : string
return string The field HTML
    public function getRepeatable()
    {
        // Get field parameters
        $class = $this->class ? $this->class : $this->id;
        $format_string = $this->element['format'] ? (string) $this->element['format'] : '';
        $link_url = $this->element['url'] ? (string) $this->element['url'] : '';
        $empty_replacement = $this->element['empty_replacement'] ? (string) $this->element['empty_replacement'] : '';
        if ($link_url && $this->item instanceof DataModel) {
            $link_url = $this->parseFieldTags($link_url);
        } else {
            $link_url = false;
        }
        if ($this->element['empty_replacement']) {
            $empty_replacement = (string) $this->element['empty_replacement'];
        }
        // Ask GenericList::getOptionName to not automatically select the first value
        $value = GenericList::getOptionName($this->getOptions(), $this->value, 'value', 'text', false);
        // Get the (optionally formatted) value
        if (!empty($empty_replacement) && empty($value)) {
            $value = JText::_($empty_replacement);
        }
        if (empty($format_string)) {
            $value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8');
        } else {
            $value = sprintf($format_string, $value);
        }
        // Create the HTML
        $html = '<span class="' . $class . '">';
        if ($link_url) {
            $html .= '<a href="' . $link_url . '">';
        }
        $html .= $value;
        if ($link_url) {
            $html .= '</a>';
        }
        $html .= '</span>';
        return $html;
    }