OroPlatform Forums

Covering OroPlatform topics, including community updates and company announcements.

Forums Forums OroPlatform OroPlatform – Programming Questions Address form – default country

This topic contains 4 replies, has 4 voices, and was last updated by  apcimino 7 years, 3 months ago.

Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.

  • Creator
    Topic
  • #33639

    jakabadambalazs
    Participant

    Is there a place where I can set the default country (i’d like to set Italy) for the Address form?
    thanks


    oro/platform(1.6.2) + oro/doctrine-extensions(1.0.7) + symfony/symfony(v2.3.27)

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #33640

    mirche
    Participant

    Same issue here…

    #33641

    mirche
    Participant

    Alright, I’ve got a solution:

    Copy the file Oro\Bundle\AddressBundle\Resources\views\Include\fields.html.twig to your own ..\Resources\views\Include\fields.html.twig;

    Edit this piece of code:

    <script type=”text/javascript”>
    require([‘jquery’, ‘oroaddress/js/region/view’, ‘oroaddress/js/region/collection’, ‘jquery.select2’],
    function($, RegionView, RegionCollection){
    $(function() {
    /** @type oro.region.View */

    new RegionView({
    el: $(‘#{{ country_field.vars.id }}’),
    target: $(‘#{{ id }}’),
    simpleEl: $(‘#{{ region_text_field.vars.id }}’),
    collection: new RegionCollection(),
    showSelect: {{ showSelect|json_encode|raw }}
    });
    });

    $(document).ready(function(){
    var el = $(‘#{{ country_field.vars.id }}’);
    var defaultValue = ‘NL’; // or any other country code
    el.select2(‘val’,defaultValue).trigger(‘change’);
    })

    });
    </script>

    Make sure you include this file into your form theme, so in ..\Resources\views\Default\update.html.twig:

    {% form_theme form with […, ‘MyAddressBundle:Include:fields.html.twig’] %}

    #33642

    Artem Liubeznyi
    Spectator

    Hi Adam and Mirche,

    There is no available option to set up a default country for now, but we will add it to our roadmap. Thanks for the suggestion!

    #33643

    apcimino
    Participant

    Any update on this?

Viewing 4 replies - 1 through 4 (of 4 total)

The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.

Back to top