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



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 )
$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;
$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:

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