• Home
  • Support
  • Forum
  • Cobalt 8
  • How to fill a select with content using user_id as parameter? (form user_id not user_id logged in)

XaRz
Total posts: 10
01 Jul 2016 18:38

Hello all,

I'm testing cobalt but I'm stuck with this kind of select field.

I want a select field filled with information stored in another type using the user_id selected on the form.

(Like a linked combobox I supose)

Structure sample what I want to achieve:

Type Profile {size,color,address,user_id}

With data: {10,red, Baker Street,956} {5,blue, Fisher Street,956} {12,pink, Plownder Street,954}

In new type shipment I want a select field filled with {red,blue} values for user_id=956 in the form in real time.

Any hints?

Last Modified: 04 Jul 2016


pepperstreet VIP
Total posts: 3,837
01 Jul 2016 22:05

Welcome to the World of Cobalt!

Hello XaRz, not sure I understand your application and workflow... but here is some information that might help you:

In Cobalt certain fields have the ability to get their data from "SQL source" parameters.
For instance Radio, Checkbox, Select, Multiple Select, List-Auto-Complete.

Related links

Documentation article with examples
Forum topic/discussion


Additional fields

Apart from that, Cobalt has some powerful Parent/Child Relation fields.
Also a useful Records field with pre-made queries and parameters for custom field value comparison.

Hope this helps.


XaRz
Total posts: 10
02 Jul 2016 07:16

Thanks for the info. In fact I was trying to use the SQL source from Select but I don't know how to add parameters in the select based in another field of the form.

As for now, I'll play with text fields for advance in my testing of cobalt.

PS:I've purchased the parent/child field for more testing, but seems that is not the feature we are talking here: Load values in a form from another type using user_id parameter in SELECT.

regards,


pepperstreet VIP
Total posts: 3,837
02 Jul 2016 11:52

XaRz Load values in a form from another type using user_id parameter in SELECT.

Sorry, I still have no "picture" of your setup and goal. Could you describe in more detail who does what?

And where does the "user-id" come from?

Are you talking about a "cascading field duo" and a 2-step process?
For instance, you select a certain UserID in a 1st field...
and then the 2nd field use this ID to show dependent values?
In other words, you want to pass the selected userID into the custom SQL?


XaRz
Total posts: 10
03 Jul 2016 10:02

Exactly.

In fact, I've the user_id in "special fields" tab inside the Author field, right?. Setting this author field I want to use his userid for quering the database for fields related to him.

Now clearer? Sorry for my english, I wish I can explain better :)

Regards,


pepperstreet VIP
Total posts: 3,837
03 Jul 2016 15:00

XaRz Setting this author field I want to use his userid for quering the database for fields related to him.

Do you really want to change the author of the current record? (Doesn't make much sense to me)

By the way, did you read the documentation article and see the SQL examples for "relation"? This should give you step-by-step examples. From simple queries, and even how to get additional field values.

You don't have to get the record author programatically, it is already available and you can use the special "placeholder" [AUTHOR_ID] in your query.


XaRz
Total posts: 10
04 Jul 2016 10:03

Hello pepperstreet,

You're absolute right in all. I don't want to change the author record and I've completely missunderstood the parent/child field relation possibilities.

Now I've solved this doing:

  • Create a parent type: customers
  • Create "child types": machines, personal, etc.

In each types I need to create one field for every relation: Example:

  1. First in the child type machines I create a field relation(child) called customerid related to customer type
  2. Then in the customer Type (parent) I create a field relation (parent) pointing to the field relation child in machines created above (customerid).

Then when I add a new customer, after saving, I have the possibility to add machines or attach an existing ones.

Problem solved.

Thanks. Now I'll continue testing the visualization of the fields.

Regards,


pepperstreet VIP
Total posts: 3,837
04 Jul 2016 13:26

XaRz Problem solved.

Congrats! Glad to hear that.

Now I'll continue testing the visualization of the fields.

That's the strong part of CObalt and Relation fields. Everything has selectable templates/overrides! ;)


pepperstreet VIP
Total posts: 3,837
04 Jul 2016 13:28

XaRz when I add a new customer, after saving, I have the possibility to add machines or attach an existing ones.

Yes. The best part is that assignment is done via AJAX. You don't have to go in record edit mode!

Powered by Cobalt