I need to auto fill just one field in a form based off a dropdown selection populated by another tbl

wqwi853

Member
The desired behavior I'm looking for is when you select an option in a dropdown on a form that it will auto fill a field in the form from a different list/table.

I have a dropdown element that is using php eval to populate data from a different table from a completely different list. It works as intended.

I want to also grab a different field from that same table that populates the dropdown and autofill one text field in the new form.

For instance. I have a dropdown that concats names from a name table/

"$db = JFactory::getDbo();
$db->setQuery("SELECT id, CONCAT(last_name, ', ', first_name, ' ', middle_initial) AS fullname FROM names");
$rows = $db->loadObjectList();
foreach ($rows as $row) {
$options[] = JHTML::_("select.option", $row->fullname);
}
return $options;"

I also have an ID field in the names table that needs to be autofilled into my new form that uses a new list.

So when someone selects a name from the dropdown, it will autofill the ID into the form when someone is adding a new entry.

What would be the best way to accomplish this in Fabrik?
 
Why not use a join element, which CONCAT's the label, rather than rolling your own?

That would also enable you to use the form autofill plugin to autofill other field in your form based on the selection from 'names'.

-- hugh
 
Okay, so I took your advice and created a join element and did a CONCAT on the label. Works great.

Now I'm using the autofill plugin on the form and it seems to be working or at least finding the right data but isn't autofilling my element on the form.

I'm using {{"names_list___name_id}":"form_plugin_autofill___name_id"} in the map data text box where {names_list___name_id} is from the lookup table from the other list and the form plugin autofill placeholder is the element name for the field in the new form I want autofilled. I select a name and it appears to do a successful lookup but nothing s getting autofilled into the ID field.
 
I got it working. I didn't know that "form_plugin_autofill" was just an example. I put the full element name from my current form in there and it worked like a charm.
 
I am using a join element and for the most part it's working.

A new problem I've run into is that the join element in conjunction with the autofill element only appears to work on new entries and not when I'm editing existing records. Even though I have the autofill plugin to update the field on new and on edit... Not sure why that's happening.
 
Yes, actually.

I have an image that can be uploaded on the form but it only allows you to upload one image. When I go into the edit screen of the form it's putting out this javascript error "Error: Syntax error, unrecognized expression: #alreadyuploaded_70_/images/rTTZGr.jpg". Now, I'm not trying to reupload an image or anything. It's just seeing that from the upload element and putting out that error for some strange reason and it seems to affect my autofill plugin.

That explains why it's working on new records but not the existing ones. I don't know why the upload element is thinking I'm trying to reupload the same image again upon edit.
 
We are in need of some funding.
More details.

Thank you.

Staff online

Members online

Back
Top