Joomla 3.9.10.

I have custom component. In admin panel I show items list from one DB table with JModelList.


class MyComModelMyCom extends JModelList {

  public function getItems() {
    return $items;


<form action="index.php?option=com_mycom&view=mycom" method="post" id="adminForm" name="adminForm">
  <table class="table table-striped">
        <th><?= JHtml::_('grid.checkall') ?></th>
        <th><?= JText::_('COM_MYCOM_TITLE') ?></th>
        <th><?= JText::_('COM_MYCOM_MYBOOLEAN') ?></th>
      <?php if (!empty($this->items)) : ?>
        <?php foreach ($this->items as $i => $item) : ?>
            <td><?= JHtml::_('grid.id', $i, $item->id) ?></td>
            <td><?= $item->title ?></td>
            <td><?= $item->myboolean ?></td>
        <?php endforeach; ?>
      <?php endif; ?>
  <input type="hidden" name="task" value=""/>
  <input type="hidden" name="boxchecked" value=""/>
  <?= JHtml::_('form.token'); ?>

There is one field with type 'boolean'. I want to change value from list table like standard field 'published'.

How can I do it? Is there any magic class in JHtml? Or what should I look for?

  • You want to translate $item->myboolean to published or unpublished based on the true|false boolean value?
    – mickmackusa
    Aug 13, 2019 at 8:07
  • 1
    I guess you mean the Toggle functionality. Right?. Aug 13, 2019 at 20:48
  • @Ivan What exactly does "I want to change value from list table like standard field 'published'." mean? Please describe what you seek differently.
    – mickmackusa
    Aug 13, 2019 at 22:45

1 Answer 1


MySQL offers BOOLEAN data types via `TINYINT(1) which means it is storing zeros and ones.

Regardless of if you are evaluating true|1 versus false|0, you are still dealing with truthy versus falsey values.

PHP offers loose comparisons so you don't need to be specific about the data type when writing a conditional.

If you just want to translate the column value as published or unpublished, here is a simple inline condition (ternary) technique:

<?= $item->myboolean ? 'published' : 'unpublished' ?>

Of course if you want language flexibility, you could write all-caps language placeholders and leverage your language .ini files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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