1

I've written a bunch of custom components and only one of them has the following problem. When I click on an individual row in the component's admin list to edit it, I get the infamous:

"Error Check-out failed with the following error:"

Now, sure, we've all had this error in Joomla, however, there's usually more information with it, such as, I don't know, AN ERROR??? I've turned up the error level to the max, searched the PHP logs, set the Debug System on and still there's nothing to be found. It's worth noting that the "error" doesn't really stop me from accomplishing the edit, except for the fact that when I click Save & Close the data is saved though the page flow doesn't return to the admin list. I have to click the Cancel/Close button to go back.

I created this and other working components using Component Creator I override none of the table methods and only the save method in the model.

Also worth noting is that I did a Global Check-In as well as scoured the database for any related checked out values and found none. I think the "Check-out" is a red herring.

Any ideas on how to debug this issue further are welcome.

Table class:

<?php
 defined('_JEXEC') or die;
 /**  * clubofficer Table class  */ 

class Curling_org_dataTableclubofficer extends JTable {
    /**
     * Constructor
     *
     * @param JDatabase A database connector object
     */
    public function __construct(&$db) {
       parent::__construct('#__curling_club_officers', 'id', $db);
    }
}

Regards, Rob

1

This error will be shown when you try to edit a row and left it without check in. Check in your main controller (i.e. ComponentNameController class in your controller.php), the code like this:

if ($vName == 'form' && !$layout && ! $this->checkEditId('com_componentname.edit.itemname', $id))
{
    // Somehow the person just went to the form - we don't allow that.
    throw new Exception(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id), 403);
}

You may want to add check in button in your list to quickly check in such rows.

<?php if ($item->checked_out) : ?>
    <?php echo JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'itemname.', $canCheckin); ?>
<?php endif; ?>

And finally, the following are the requirements for you to properly use Joomla form functionality.

  1. You need to have two columns in your database table - "checked_out", "checked_out_time"
  2. Override JControllerForm in your sub controller (for form page).
  3. You can override allowEdit of JControllerForm to restrict user from check out the row if you need to check some permissions etc.

Finally use yourcontroller.save ("task" parameter of your form action or a hidden field) method to properly check in the row. If you use yourcontroller.apply method, it will keep the row checked out until you save.

e.g

<button type="button" onclick="Joomla.submitbutton('controllername.save')">Save</button>

or in your admin form view, add the toolbar button to save

JToolbarHelper::save('controllername.save');

Update: Here are some possible cases for this error to occur:

  1. Unable to load row into your jtable class (check if JTable class defined properly for your item)
  2. You are trying to check out a row which another user already checked out (this may not be the case as you said all your table rows has checked_out value as 0)

So I believe the issue is with your table class.

  • Thanks for your message. However, I guess I'm not being clear that there is absolutely nothing checked out. No way, no how. I've already tried several of your suggestions, including putting in debugging statements that check if the object is checked out and it simply is not. In the table being edited ($this->item->checked_out), there are no rows where checked_out is set to anything other than 0. This one specific admin view out of the dozen or so that I have with this component has this error. All the other views are fine. – Rob May 10 '15 at 16:23
  • Just check in your database table what value is set for the corresponding row for fields "checked_out" and "checked_out_time". If they are 0 and '0000-00-00 00:00:00', then there must be something wrong with your code, otherwise it is expected behavior. – Nagarjun May 10 '15 at 17:24
  • Let me be as clear as I possibly can - there are NO rows that are anything but 0 and '0000-00-00 00:000:00' in any of my tables. I have no doubt whatsoever that there is something wrong with my code. I just have no clue where to start looking because the error doesn't point me to anything. Every bit of debugging I've tried has led me nowhere. – Rob May 10 '15 at 23:29
  • I have added all possible cases of how this issue can occur in my answer. Post your table class code to understand it better. – Nagarjun May 11 '15 at 2:29
  • You inspired me to look at the table class. As I suspected, I didn't need most of the code in my table class (I used Component Creator to make my component). I limited my class to only the constructor and then commented out the one line in the constructor and the error went away. Of course I can't really afford to get rid of that line because my data is not present. Does this help? I added the full contents of the table class to the original post. – Rob May 11 '15 at 23:42

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.