• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

How to Update Related Records if Checkbox is checked

Tessa

Member
Hello!

I have "table_foo" and "table_bar".
table_foo has many table_bar (one to many relationship).

Well, i have a copy of table_bar that has a checkbox that says "Update All?", so instead of updating the individual record, it will update all related records. Note that there is no JOIN because it will mess up editing the form the way it's set up.

I understand I need to add a custom PHP form script, do you have any examples of a related situation?


Here's the real situation:

I have table Model and table Sizes.

I have a copy of the Size table, and want to have an option to edit a record and include some data that is unique to all the sizes of the model, or if the "Update All" checkbox is unchecked, it would only update that size itself.

Looking forward to a response. :)

Tessa

Latest Joomla 2.5.x version
Updated from Github like 2 weeks ago
 
Update, looks like I have to join the 2 tables together although I mentioned I wasn't. Have to filter by elements from Parent table. lol
 
hi Tessa is this question still outstanding - or did the join resolve the issue?
-Rob
 
Hi Rob, strange I didn't receive a notification of your response. :p

I didn't find a solution yet. Any recommendations or resources?

Thanks!
 
I guess you would need a php form plugin on the Model form to get the data submitted and update the related records in the sizes table. so pseudo code:

PHP:
$app = JFactory::getApplication();
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$rowid =  $app->input->get('rowid');
$updateValue = $app->input->get('model_common_info');
$query->update('sizes')->set('common info = ' . $db->quote($updateValue)) ->where('sizes.model_id = ' . $db->quote($rowid));
$db->setQuery($query);
$db->query();
 
Thanks again for the help, but I'm not seeing how this would work if I selected a checkbox and if the checkbox is checked, then it should update all the related records (all sizes) to that model.

I can't wrap it with if (checkbox == "1") because there is no value assigned to it. It has to happen if checked and before form is submitted.

PHP still confuses me. You'd think I'd figure it out after this long LOL :)

Kindly awaiting a response. :)




I guess you would need a php form plugin on the Model form to get the data submitted and update the related records in the sizes table. so pseudo code:

PHP:
$app = JFactory::getApplication();
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$rowid =  $app->input->get('rowid');
$updateValue = $app->input->get('model_common_info');
$query->update('sizes')->set('common info = ' . $db->quote($updateValue)) ->where('sizes.model_id = ' . $db->quote($rowid));
$db->setQuery($query);
$db->query();
 
Great article Rob! I'm still a bit inexperienced when it comes to JS.

I tried to paste my code but it got wiped a few times, so I am using a pastebin type of site.

Is this any closer? The JS is messed up, but you see my idea? :-D

http://snipt.org/XBm8
 
Hi Tessa
Probably best to catch me on the chat to discuss this one ;) I'm online for the next 9 or so hours
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top