Checkbox element - how to make no checkboxes until user adds them

always still show in the parent fabrik list (weather the check boxes are checked or not)

Not sure what you mean by this. How are you picturing that, in list view? In read-only contexts, we just display an unnumbered list (UL) of the selected labels. Not sure how we'd represent un-checked ones.

-- hugh
 
Hi Hugh.
Yes, it?s an odd question; but the application makes sense. The correct DJoin checkbox labels list appropriately in the list; but only if they are checked in the related form. If they are unchecked then they vanish from the parent list. The problem is that others users want to be able to always see the PO#s (labels) in the list weather they are checked or not. They want the check box beside each label in the form to represent that the related material delivery for each checked off PO# (label) has arrived and not weather it appears in the parent list or not. Does that make sense and, if so, can it be done?
Thanks in advance.
 
I can't think of a way of doing that with the join element. Can't even do it with layout overrides, as the join element is one of the few that doesn't have it's own list layout, it uses the generic element model one, and by the time that layout is run, the non-selected label data is gone.

The only way to do it would be with some custom code, either in a custom template, or maybe a calc element. The calc element would have to query the join table, get all the labels, and render them. Then you could display the calc instead of the join element in the list.

-- hugh
 
Cool. I knew you would have a good direction to send me. I?ll give it a try.
Thanks Hugh. I appreciate it.
 
Hi Hugh. Any chance you can share a generic sample of the php code for me to add within the calc element settings?
Thanks in advance.
 
Hi Hugh. I tried using the calc element; but for some reason I was getting an error page. So, I switched it to a display element instead and turned on Eval. So, the furthest I got was replicating what the DBjoin was doing on the list using the following in the display element default setting.
Code:
return '{bw_projects___po_checklist}'';

So, next I need to do the "query the join table, get all the labels, and render them" part that you recommended. This is where I could use some help or an example.
I took a look at the Common PHP Tasks and I think I need to do the portion that says the following.
Load a single ROW of data as an object:
PHP:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);

$myQuery
->select(array('fieldA', 'fieldB'))
->from('tablename')
->where('fieldC = ' . $myDb->quote('value'));

$myDb->setQuery($myQuery);

$row = $myDb->LoadObject();

Note: In additional to loading by table name, if you know the $id of the record you wish and want to load it from the list name (instead of table name), you can use the Fabrik List Model like this...
PHP:
$row = $listModel->getRow($rowId);

If so; I could use some clarity on the specifics. For instance, can "$row = $listModel->getRow($rowId);" be used in this case instead of all of the above? If so, do I then return $row? I apologize for maybe asking some basic stuff; but I couldn't find a real example in the forums that I could substitute with my real table, field, list and element names. Sometimes I just need it as clear as speaking to a 5 year old, LOL.
Thanks in advance and I hope to hear from you soon.
 
I just read the whole thread again, and if I'm understanding correctly, the selections you want to show from the other table are where 'fid' is the foreign key (points to the rowid id of the main form).

Code:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->select('your_label_element')->from('the_other_table')->where('fid = "{rowid}"');
$myDb->setQuery();
$myResults = $myDb->loadColumn();
if (!empty($myResults)) {
   return '<ul><li>' . implode('</li><li>', $myResults) . '</li></ul>';
}
return '';

Obviously replace the field and table names int he query as appropriate. That should return a list (UL) of the labels.

-- hugh
 
Hi Hugh.
I tried your suggestion with the following; but it generated an error right away when I brought up the list.
Code:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->select('bw_projects___po_checklist')->from('bw_projects_repeat_po_checklist')->where('fid = "{rowid}"');
$myDb->setQuery();
$myResults = $myDb->loadColumn();
if (!empty($myResults)) {
   return '<ul><li>' . implode('</li><li>', $myResults) . '</li></ul>';
}
return '';
Then I looked back on what I wrote earlier in this thread; especially when I was wondering where the fid variable came from. The problem is the fid only gets saved when a form is opened in the form php plugin. I only have this display element visible on the list. The point is to list all of the DBjoin items in each record within the parent list; regardless if they are checked or not. So, not sure if I also need to generate a fid variable with maybe a php list plugin to make this work? Or, maybe I'm not looking at this right? Any suggestions?
Thanks in advance and I hope to hear form you soon, Hugh.
 
I've just totally lost the plot on what's what in your setup.

Maybe try 'parent_id' instead of 'fid'.

If that doesn't work, we may just have to do this as a small piece of billable work. There's a limit to what I can do in the forums, especially when it comes to this kind of looong thread where I can't see what you are actually trying to do, and writing code becomes an exercise in guesswork.

-- hugh
 
Hi Hugh. I took a better look at your recommendation and realized I was applying it wrong. I revised the calc element PHP to the following and it worked!
Code:
$myDb = JFactory::getDbo();
$myQuery = $myDb->getQuery(true);
$myQuery->select('po_number')->from('bw_pos')->where('fid = "{rowid}"');
$myDb->setQuery($myQuery);
$myResults = $myDb->loadColumn();
if (!empty($myResults)) {
   return '<ul><li>' . implode('</li><li>', $myResults) . '</li></ul>';
}
return '';
This calc element also is nicely hidden in the form and my DBjoin with checkboxes is displayed. So, it works; until I click on the save button in the form and the attached/following error page appears:
Unknown column 'bw_projects_repeat_po_checklist.fid' in 'where clause' SQL=SELECT `bw_projects_repeat_po_checklist`.id AS id,`bw_projects_repeat_po_checklist`.parent_id, `bw_projects_repeat_po_checklist`.`po_checklist` AS value, `bw_pos`.`po_number` AS text FROM `bw_projects_repeat_po_checklist` LEFT JOIN bw_pos ON `bw_pos`.`id` = `bw_projects_repeat_po_checklist`.`po_checklist` WHERE `bw_projects_repeat_po_checklist`.fid='9912'
Not sure why. If I unpublish the calc element then there error page goes away. I'm so close and I'm hoping that you'll notice something obvious that I'm missing hear. Any suggestions?
Thanks in advance.
 
Hi Hugh.
I?ve been searching the forum threads trying to find an answer to my last error and I came across one where you recommended a solution using a PHP form plugin that would update a regular field element with data; per the following.
Instead of trying to solve my last error with the calc element; I?m wondering if I should abandon the calc element and do something similar. If this sounds like it would work; should I use a textarea element versus a regular field element because of the possibility of displaying a long unordered list? Any suggestions?
Thanks in advance and I hope to hear from you soon.
 
That error looks like a join element adding a filter query when building a list filter.

Do you have any "filter queries" on bw_projects_repeat_po_checklist?

-- hugh
 
Hi Hugh.
Not sure. The bw_projects_repeat_po_checklist table was automatically created by Fabrik when I created the bw_projects___po_checklist DBjoin element. Is the "filter queries" setting within bw_projects___po_checklist DBjoin element? If so; could I trouble you to share where within I would find this setting?
I only found the "Include in list query" setting in "List view settings > List settings tab"; which it was on and I turned it off. I also changed the "Filter Type" setting to "None" in the "Filters" tab. I then tested and had the same error page only when I press the form submit button. If I close the page and reopen in the related list then everything looks fine. Maybe I'm looking in the wrong place...
Or, maybe you meant what we added in the "Details > Data - where" at the beginning of this thread within the bw_projects___po_checklist DBjoin element (see the attached snippet)?
Thanks in advance.
 
Last edited:
Hi Hugh.
I'll clone the site and redo mySites again tomorrow. I'll let you know when its ready.
 
Last edited:
Hi Hugh. OK, sorry for the delay. It's been a really busy week. I finally cloned my live site to mySites. If there's any way you could take another look into this it will be greatly appreciated. I feel it's so close because it works; but just creates that error page every time the form submit button is pressed during a form edit & not a form add/new (only if the "bw_projects___po_checklist_listonly" element is published). I added a new job (site name) record to the material shelf page "Test site 1" and I added a couple PO checklist numbers; which appear in the list correctly and also the form correctly. It just took an error page, closing the web page and reopening to the list to get it there.
Thanks in advance, Hugh.
 
I think the only way I can help you fix this is by getting an Akeeba backup of your site, installing it here, and stepping through the code in debug mode. Which is something I'd have to charge for.

Also, even to take a look on your site (I'm logged on now) I need explicit instructions on how to replicate the error. Like which row of which list to edit, and whether I need to be on the front or back end, who I should be logged in as (I notice you have the WHERE clause on that join set to apply only to Project managers) etc.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top