From 07651ea8e18544a0ff67dee2e8120110afe09d4b Mon Sep 17 00:00:00 2001 From: Amigo <49749100+aamigo@users.noreply.github.com> Date: Tue, 18 Jun 2019 15:31:46 +0200 Subject: [PATCH] Updated 030 How to filter a list field based on association with another field (markdown) --- ...lter-a-list-field-based-on-association-with-another-field.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/030-How-to-filter-a-list-field-based-on-association-with-another-field.md b/030-How-to-filter-a-list-field-based-on-association-with-another-field.md index d3eafe0..bfbb330 100644 --- a/030-How-to-filter-a-list-field-based-on-association-with-another-field.md +++ b/030-How-to-filter-a-list-field-based-on-association-with-another-field.md @@ -35,7 +35,7 @@ Another thing I'm almost skipping it, this select_a_region [00:09:55](https://ww Now the region button is actually a JavaScript [00:12:22](https://www.youtube.com/watch?v=Z8FLifQOjUk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m22s) that is added because of the list field. so if your specific list field was set to have no button, you could simply leave this out. If it was set to have a button, the name of the button would be this area before the jform_. This part(region) of the name would be the first part of the name of the button function, and then the last part would be button. [00:12:54](https://www.youtube.com/watch?v=Z8FLifQOjUk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h12m54s) So that's how you can on the page let it execute and search for this(regionButton) function, if you aren't sure. That's how you would run the button correction. And that's how JavaScript looks to achieve this. There is a little bit more housework necessary and that's what I said before. This area of JavaScript can actually include [00:13:25](https://www.youtube.com/watch?v=Z8FLifQOjUk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h13m25s) PHP. That area can not because that's just pure JavaScript file. Where's this is JavaScript added to a PHP file. Here we can add some PHP and that's where we get the select_region and create_region. -### JavaScript +### JavaScript - AdminForm.on(change) Now I know there is another way to do this in Javascript itself. There's this function, the adminForm.on(change) of the country field is when that event occurs, we want to execute getRegion. [00:14:06](https://www.youtube.com/watch?v=Z8FLifQOjUk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m06s) That is done every time that field is changed. What is the extra bit of Script that you need to add these two. If you are going to copy this down exactly the same. Just another note. That will execute this function. Which is the same function that we are executing [00:14:33](https://www.youtube.com/watch?v=Z8FLifQOjUk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&t=00h14m33s) on the page load. We don't need to execute this. Simply because that is already been done on the page load. That is all the JavaScript that you need to add.