Change boolean field in JModelList table like "published"

by Ivan Ankudinov   Last Updated August 13, 2019 08:10 AM - source

Joomla 3.9.10.

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

models/mycom.php:

class MyComModelMyCom extends JModelList {

  public function getItems() {
    ...
    return $items;
  }
}

views/mycom/tmpl/default.php:

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

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?



Related Questions



Store data to other table and get the id

Updated June 29, 2015 13:04 PM



Complex MySQL-Query

Updated April 07, 2015 18:04 PM