Updated 030 How to filter a list field based on association with another field (markdown)

Amigo
2019-06-18 15:31:46 +02:00
parent 4a49320b97
commit 07651ea8e1

@@ -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.