Populating multiple fields from pulldown list

5 posts by 2 authors in: Forums > CMS Builder
Last Post: February 25, 2016   (RSS)

By lozzer - February 22, 2016

I have a slightly tricky query to explain!

I have a CMSB setup which has a 'report' section, where performance is recorded for an individual person at several times. The report only contains four fields (First Name, Last Name, Date of Birth and ID) relating to the person, with a further dozen fields for each 'performance'. Rather than having to input those four fields each time, I'd like to be able to select an individual from a pulldown list in the Section Editor to populate those four blank fields.

I have been able to get the pulldown list working OK using the following MySQL query:

<?php $numValue = (@$ESCAPED_FILTER_VALUE )? $ESCAPED_FILTER_VALUE : '0'; ?>

SELECT num, CONCAT(FirstName,' ', LastName, ' [', ID,']')
FROM `<?php echo $TABLE_PREFIX ?>report`
WHERE num != <?php echo $numValue; ?>

But I cannot figure out how to make the selection populate then populate those four fields. Any help gratefully received!

Hi lozzer,

It would be possible to create a system that does this, but you'd need to build a small plugin to add the values when the user saves the record. You'd be able to do this with the plugin hook record_postsave. 

Is there a particular reason you need this information added to the performance record if it's already stored against the person record? The best solution seems to be to have a single drop down field where you select the user, and it displays the their first name, last name, DOB, then you wouldn't need to have the extra fields. Also, if a user changes their name, you wouldn't have to go through each performance record and update the name field as well. 

Let me know if you have any questions.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

Hi  lozzer,

This is something we would be able to help with. if you email consulting@interactivetools.com with the details of the site, we can give you an estimate for either creating a plugin to add the missing details, or to import the CSV data so that those fields aren't required. 

Let me know if you have any questions.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By lozzer - February 25, 2016

Thanks Greg. I've had a couple of emails from Ross, so I hope we'll get it sorted! Lozzer