8 years ago
6
Topic

Hi All,

I have created a dynamic field called 'article_id' to get articles ID. But I want to view only articles created by a user id entered in the field user_id on my current form. How can I reference user_id field in my where created_by =  user_id on the actual form ? 

I purchased the Select dynamic cascade field but it can't help me in this case because user_id should be manually typed in or passed by the previous form. Select dynamic cascade doesn't allow manual entry.

Get a Book for SEBLOD
4229 Posts
Kadministrator
8 years ago
1
Level 1

With select dynamic cascade you can have the first select selecting users and have their ids as values and if you use conditional "is filled by" you can set it to pick user_id value whenever it is chaged. Then your second cascade can use first cascades value to filter articles by user id.

8 years ago
0
Level 2

Thank you Klas for your answer. Using conditional state, I am able to fill the user_id automatically to the first select field but the issue now is that it doesn't trigger the change on the second field. So the the second field show no article. How can I fix the issue. I saw another suggestion from you on this post https://www.seblod.com/community/forums/fields-plug-ins/select-dynamic-cascade-conditional-state  I tried it but it messed up all the form instate. Is there a better solution? 


Thank you in advance.

4229 Posts
Kadministrator
8 years ago
3
Level 1

Hi,

you need to manually trigger change event on the first select dynamic cascade field, when value if article_id field changes. Just replace field ids in the following code with real ones (you can find field id by looking at the html source code of your page) and put this in on of the js fields on the page

$( "#article_id_field_id" ).change(function() {

$( "#first_cascade_field_id" ).change();

});

8 years ago
2
Level 2

Thank you Klass for your answer. But I still can't get it to work. here are my actual field ID's

user_id_note  = simple input field where user id is entered manually

member_id2  = First select dynamic cascade field automatically filled out with value from  user_id_note using conditional state

device_id_note = second select dynamic cascade field ( i am unable to get updated properly after member_id2 has been updated

Here is what I did.

In the user_id_note properties, I added the following code under Scrip (JS)

But the behavior is not what I expect. When I type 788 as user id in user_id_note, member_id2 is well updated but device_id_note is not. If i then enter any other id ,  member_id2 will be updated with the new id but device_id_note will be updated with the previous ID. so to populate the second select with articles from user 788, i need to enter 788, type enter and type any other ID. Any idea on how it is working like this?

$( "#user_id_note" ).change(function() {

$("#member_id2").change(); });

}

8 years ago
1
Level 3

When I use click(function) like below it works. But it doesn't help me in my project because the input field will be hided and updated automatically. I have to find a different way. 

$( "#user_id_note" ).click(function() { 
 $( "#member_id2" ).trigger('change'); 
});
4229 Posts
Kadministrator
8 years ago
0
Level 4

I just tested an this works for me - but first remove conditional as value will be copied with this javascript:

$( "#user_id_note" ).change(function() {
value = $(this).val();
$( "#member_id2" ).val(value).change();
});
Get a VIP membership