2

I have a Joomla-site with a lot of extra-fields in custom fields area. When I edit my articles the long list of fields is quite confusing. So I thought I could be a good idea to show the custom fields in backend in two columns like it is in the "images and links"-tab. Don't know what I mean. Look here for an example: Custom-fields backend

Of course I could write my own override for the template, but where the hell is the view of fields-tab in backend built up? The individual fields are in a container named "control-group" but I don't find the pivotal file in /administrator/components/com_fields

Could anybody please help me out of this dilemma? Thank you very much!

1 Answer 1

2

Custom Fields are added to forms by System - Fields plugin.

Before doing template override I suggest checking out Field Groups feature. Each field group has its own fieldset which results in a separate tab in form view: enter image description here

If this solution doesn't suit you, you can override form view layout:

administrator/components/com_content/views/article/tmpl/edit.php

In the override add fields-0 fieldset to ignored fieldsets array:

$this->ignore_fieldsets[] = 'fields-0';

And then render the fields manually:

<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'fields', JText::_('JGLOBAL_FIELDS')); ?>
    <div class="row-fluid form-horizontal-desktop">
        <div class="span6">
            <?php echo $this->form->renderField('field-1', 'com_fields'); ?>
        </div>
        <div class="span6">
            <?php echo $this->form->renderField('field-2', 'com_fields'); ?>
        </div>
    </div>
<?php echo JHtml::_('bootstrap.endTab'); ?>

You can also combine both methods to avoid having to render each field by name and instead use fieldsets (field groups). E.g. create two field groups, assign fields to them. In the override exclude the groups:

$this->ignore_fieldsets[] = 'fields-1';
$this->ignore_fieldsets[] = 'fields-2';

And then render them:

<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'fields', JText::_('JGLOBAL_FIELDS')); ?>
    <div class="row-fluid form-horizontal-desktop">
        <div class="span6">
            <?php echo $this->form->renderFieldset('fields-1'); ?>
        </div>
        <div class="span6">
            <?php echo $this->form->renderFieldset('fields-2'); ?>
        </div>
    </div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
6
  • Thank you very much. The solution with groups isn't suitable for me, because i this case the large number of fields is only divided into two or more long columns. The file you mentioned "administrator/components/com_content/views/article/tmpl/edit.php" is creating the main content and the publishing-tab etc. but not the fieldset. When I add the line <?php $this->ignore_fieldsets[] = 'fields-0'; ?> it unfortunately doesn't change anything... Maybe it is another file??? Feb 22, 2019 at 8:24
  • That line has to be added after this: $this->ignore_fieldsets = array('jmetadata', 'item_associations');. Or you can add fields-0 in the same line: $this->ignore_fieldsets = array('jmetadata', 'item_associations', 'fields-0');. Also, instead of editing the file directly you should override it. See override documentation: docs.joomla.org/….
    – Sharky
    Feb 22, 2019 at 8:36
  • Yeah of course I'll do an override... At the moment it is just for testing the behaviour. Thank you, now I understand it better... Feb 22, 2019 at 8:48
  • btw. in my joomla-installation it isn't possible to choose the fields-group in the fields. When I click on it it shows only "none" And another thing is... Why isn't it possible to change the type of an field after creating it... But therefore I can handle it via sql... But thanx again. I think this will help a lot... Feb 22, 2019 at 9:03
  • You have to create a field group before you can select it. Changing field type would cause various issues, e.g. some fields would not display correctly because some types stores values as text while others store as JSON object or array.
    – Sharky
    Feb 22, 2019 at 9:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.