Categories
CMS Joomla Mastering Development

Own Custom Field Plugin – Multiple Inputs

I am currently creating a custom field plugin for Joomla! I am now faced with the task / problem that the user needs more than just one field when adding the information. In detail it is so that it is a map plugin and the user can enter the coordinates in a field and set the label and the description (field type text & textarea) for the marker popup. So my plugin should not only be able to output one field type text in the backend but two text fields and a textarea.

I already tried to generate the fields and return them comma-separated or in an array (hoping this application scenario exists) which unfortunately failed.

most of the work for this plugin is done but is there a way to have multiple fields rendered?
i know it is a custom field plugin not a custom fields plugin, but maybe…

class PlgFieldsPluginName extends FieldsPlugin{
protected $hint = '46.856112,9.517915';

public function onCustomFieldsPrepareDom($field, DOMElement $parent, JForm $form)
{
    $coordsField = parent::onCustomFieldsPrepareDom($field, $parent, $form);
    if (!$coordsField)
    {
        return $coordsField;
    };

    $coordsField->setAttribute('hint', $this->hint);
    $coordsField->setAttribute('description', JText::_('NX_BINGMP_VALUE_DESC'));
    

    return $coordsField;
}
}

As a completion: I am talking effectively about the area when you enter data in an article field. Not about the plugin parameters or the field parameters that are solved via XML.

Leave a Reply

Your email address will not be published. Required fields are marked *