Toggling one list based on input of another

Status
Not open for further replies.

bespokeappstt

Hubstaff freelancer
I have a list called 'Equipment' and two elements called SerialNumber and Availability. Availability has the values 'Yes' or 'No' using a dropdown. SerialNumber is self-explanatory. Now there is another list called 'Rental' and it also has an element called SerialNumber that is a 'databasejoin' on the 'Equipment' list, SerialNumber. I want to be able to create entries in the 'Rental' list and every time a 'SerialNumber' is chosen the 'Availability' is toggled to 'No' in the 'Equipment' list for the row of data with that SerialNumber. SerialNumbers are unique and can only be listed in the 'Equipment' list once. If I hard code the 'SerialNumber', the php form plugin code works. So the issue I am having right now is grabbing the value of 'SerialNumber' from the rad_rentals___serial element. The documentation says for a databasejoin dropdown, the values are in an array and it then goes on to show how to get the first value. But it doesn't show how to get the value the user actually selects. How do I get the value the user actually selects. Here is the code
Code:
//Hard coded value works
//$serialNumber = '564789985155';
$serialNumber = $formModel->getElementData('rad_rentals___serial', true);
$serialNumber = is_array($serialNumber) ? $serialNumber[0] : $serialNumber;



// Get the db and the query
$db = JFactory::getDbo();
$query = $db->getQuery(true);

//Field to update
$field = 'available = 0';

//Reference column
$conditions = 'serial_number' . '= '. $serialNumber;



    $query->update($db->quoteName('rad_serialassets'))->set($field)->where($conditions);

$db->setQuery($query);

$result = $db->execute();
return $result;
 

Attachments

  • serialAssetsDataView.png
    serialAssetsDataView.png
    62.6 KB · Views: 80
  • rentalList.png
    rentalList.png
    78.7 KB · Views: 82
  • rentalDataView.png
    rentalDataView.png
    64.3 KB · Views: 82
  • Processscript.png
    Processscript.png
    53.7 KB · Views: 80
  • assetsList.png
    assetsList.png
    59.4 KB · Views: 82
@lousyfool This is not a Joomla syntax issue. This is entirely a Fabrik issue. As I mentioned if I hard code the SerialNumber everything works. It breaks when I introduce the Fabrik code block. Not sure how this ended up here. That really strange. I'll copy and paste to 3.0
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top