• 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.

Get rowid of detail view and pass value to php plugin of form module

aijosh

Member
Hello,

I have a form module on a detail page.

I need to read the rowid of the detail and pass it to the php plugin of the form module for use in processing the form submission.
 
well I need to proceed with making this work so I extracted the formid and rowid from the url using php form plugin - onload - then specified what list to search. I dont think this is the best solution but it works (as long as the url's format doesn't change )
PHP:
$url  = '{$_SERVER->REQUEST_URI}';
//extract texts between slashes of url
list($slsh, $page, $viewtype, $formid, $rowiddirty, $trail) = explode("/", $url);
//remove everything except numbers
$formid = preg_replace("/[^0-9]/", "", $formid);
$rowid = preg_replace("/[^0-9]/", "", $rowid);
if ($viewtype == "details") {
$mdb = JFactory::getDbo();
  if ($formid == "1"){
  $mdb->setQuery("SELECT needed FROM tblx WHERE (id = $rowid)");
  } elseif  ($formid == "2") {
  $mdb->setQuery("SELECT needed FROM tbly WHERE (id = $rowid)");
  } elseif  ($formid == "3") {
  $mdb->setQuery("SELECT needed FROM tblz WHERE (id = $rowid)");
  } elseif  ($formid == "4") {
  $mdb->setQuery("SELECT needed FROM tblw WHERE (id = $rowid)");
  }
$needed = $mdb->loadResult();
$formModel->data['___needed'] = $needed;
}
 
Code:
$app = JFactory::getApplication();
$formid = $app->input->get('formid', '');
$rowid = $app->input->get('rowid', '');
// rest of your stuff

As long as that's running on the page load of a details view, it'll return the formid and rowid. Even when SEF'ed. after routing the input array is correctly set with the URL components.

-- hugh
 
Well. I did try that initially. It returned the id of the search form. I need the id of the form that the current detail view belongs to and not that of the search form

I'll test and see if this would work. Your code has some quotes in it which mine didn't have but I think my guess is correct that it'll return the id of the search form
 
Ah, OK, yeah, I forgot we override the input in the form module.

If you update from github, with this commit:

https://github.com/Fabrik/fabrik/commit/8eca22aa699ad1c185386bafd68bb5ef485d7b73

... you'll be able to get them with $app->input->getInt('orig_rowid', '') and $app->input->getInt('orig_formid', '').

Those extra quotes are just setting a default for the get(), in case the item doesn't exist. I'm just in the habit of setting explicit blank defaults.

Note the use of getInt(), rather than get(), as you are using them in a query.

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

Thank you.

Members online

Back
Top