0

Recently, I add a field tag into the filter_workitems.xml, which looks like:

<field name="show_this_week" type="CheckboxCustom" label="sohw this week" description="" value="1" class="" onclick="
            var curr = new Date;
            var first = curr.getDate() - curr.getDay()+1;
            var last = first + 7;

            var firstday = new Date(curr.setDate(first)).toISOString();
            var lastday = new Date(curr.setDate(last)).toISOString();

            document.getElementById('filter_created_from').value = firstday.substring(0, 10);
            document.getElementById('filter_created_to').value = lastday.substring(0, 10);
            this.checked = false;
            this.form.submit();"/>

but found that the field attribute "label" not show as I expected, however "description" attribute show correctly. Wonder anyone know why and how to make label attribute show as it should do? Thanks for your tutoring~

Joomla version is 3.8.12

1
  • sohw this week is not rendered/visible on the page? Is the text also not presented in the generated source code? Does it work without spaces in the value? Does it work if you remove the inline javascript? It seems like a good idea to transfer that js to an external script instead of inline. Commented Sep 18, 2019 at 7:06

1 Answer 1

1

Assuming you're using Joomla's default search tools layout, it does not render labels. You can create a custom layout or a layout override specific to your component. To accomplish the second option:

Copy layouts/joomla/searchtools/default/filters.php to administrator/components/com_yourcomponent/layouts/joomla/searchtools/default/filters.php

Replace this code:

<?php $dataShowOn = ''; ?>
<?php if ($field->showon) : ?>
    <?php JHtml::_('jquery.framework'); ?>
    <?php JHtml::_('script', 'jui/cms.js', array('version' => 'auto', 'relative' => true)); ?>
    <?php $dataShowOn = " data-showon='" . json_encode(JFormHelper::parseShowOnConditions($field->showon, $field->formControl, $field->group)) . "'"; ?>
<?php endif; ?>
<div class="js-stools-field-filter"<?php echo $dataShowOn; ?>>
    <?php echo $field->input ?>
</div>

With just this:

<div class="js-stools-field-filter">
    <?php echo $field->renderField(); ?>
</div>

This will render the entire field in a standard way.

1
  • Thanks for detailed explanation. I've tried and get exactly what you said. :)
    – Ryan Ye
    Commented Dec 11, 2019 at 1:27

Your Answer

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

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