Joel Hughes
Joel Hughes

Reputation: 1

In Drupal after selecting a value in an autocomplet, I need to load field values from a database record

I am using Drupal 7's Form API to develop a prototype for an old system. I've managed to get the dropdown select boxes to load dynamically and dependently from the database. I have also managed to connect an autocomplete to the same database. Mind you, my database tables and relationships have been imported into Drupal's MySQL database so I don't have to worry about switching databases back and fourth.

Now that I have figured all that out, I need to then take the value selected and query the database based on that key, which I've also done. Since I'm used to Java and C#, I'm used to a simple textfield.value = databaseField; but this isn't how it works in Drupal.

After all this, I still can't figure out how to load the form fields with the database data I've retrieved. I'm fairly new to Drupal but have managed to figure quite a bit out. This, I thought, would be one of the simpler things; yet I can't get it to work.

Any help or examples on this would be greatly appreciated. I would also like to be able to understand better how Drupal does these kinds of things so I am able to do inserts and deletes later.

Note: I have managed to create two horizontal tab fieldsets, one for updating, and one for inserting. These two fieldsets reside in the same location on the form and depending on what I'm doing, I hide the unneeded fieldset. What I'm saying is I feel like I've done some cool stuff, but this seemingly simple and basic operation alludes me.

Upvotes: 0

Views: 116

Answers (0)

Related Questions