8.4.2 How to use StatesProvincesList with CountryList

Permalink
I can load arrays of countries and states from CountryList and StatesProvincesList into select boxes and use ajax to filter the states on selecting a country.

However I see in the address attribute code the following statement: "@deprecated Use $app->make(\Concrete\Core\Form\Service\Form::class')->selectCountry() to link a Country field and a State/Province field". I don't quite get what this means. How do I use that selectCountry() to have the two select boxes linked? API doesn't find this function.

linuxoid
 
mlocati replied on at Permalink Reply
mlocati
linuxoid replied on at Permalink Reply
linuxoid
Yes, I've seen that. I was wondering if there was an in-build link between the two and I didn't have to use JS to filter it.

This is what I've got:
<div class="row">
    <div class="col-xs-12">
        <div class="form-group">
            <?php 
            echo $form->label('country', t('Country'));
            echo $form->selectCountry('country', $country->getCountry());
            ?>
        </div>
    </div>
</div>
<div class="row">
    <div class="col-xs-12">
        <div class="form-group">
            <?php 
            echo $form->label('state', t('State'));

I was wondering if there is simpler way.
mlocati replied on at Permalink Reply
mlocati
In the example I linked above there's no JavaScript, and the two fields are linked (read this linehttps://github.com/concrete5/concrete5/blob/95e79fe32c851da4d80f1a3b... )