OroCRM Forums

Covering OroCRM topics, including community updates and company announcements.

Forums Forums OroCRM OroCRM – Programming Questions Setting Default Country in Address to Primary Location

This topic contains 7 replies, has 4 voices, and was last updated by  jakabadambalazs 9 years, 1 month ago.

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

  • Creator
    Topic
  • #24891

    Spurgeon
    Participant

    Hi,

    Greetings!

    Realise that when we set default country in the primary location field of System -> Configuration -> Localization, the changes are reflected in currency.

    It would be ideal, if this also sets the default country in the Address Entity to the primary location. As of now, it shows ‘Choose a Country…’ .

    Any idea how this can be implemented?

    Thanks!
    warm regards
    Spurgeon

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #24892

    Alexandr Smaga
    Participant

    Hi @spurgeonbj ! Sound like a good improvement for OroPlatform, thanks !

    For now you can do this by form extension that will extend oro_country form type and set default data in options.

    #24893

    Spurgeon
    Participant

    Hi Alex,

    Greetings!

    Thanks a lot for your kind response and tip and also for considering this for implementation.

    Will check out the form extension option.

    warm regards and gratitude,
    Spurgeon

    #24894

    changwuf31
    Participant

    Hi Spurgeon,

    I’m looking into this as well. But cannot find the solution yet.
    Have you solved this one?

    #24895

    Spurgeon
    Participant

    Hi Chang,

    Greetings!

    Not yet.

    But I think we can extend / override or modify (only issue with modification is we need to incorporate these changes when we upgrade) oro_country form type in the Address Bundle.

    I tried doing it by modifying and ended up getting the default country as a ‘Place Holder’ rather than the currently selected option, in my case it showed ‘India’ instead of ‘Choose a Country’ when i modified this file.

    vendor/oro/platform/src/Oro/Bundle/AddressBundle/Form/Type/CountryType.php

    I had set empty_value = ‘India’ and empty_data = ‘IN’ (dont remember whether it was the other way round). This does change the select2 control

    Guess it might be to do something with setting default country id.

    Hope Alex can help us here :-)

    Do let me know if there’s any update.

    Thanks!
    warm regards
    Spurgeon

    #24896

    changwuf31
    Participant

    Ah, thank you for the response Spurgeon,

    I think we should use a javascript solution here, as changing the country, should also trigger the state ajax.

    Yes, sure hope Alex or someone from orocrm can help here :)

    #24897

    Spurgeon
    Participant

    Hi Chang,

    Greetings!

    Thanks for the quick response.

    That sounds great!

    If you are comfortable in Javascript, you can check this file

    which handles the events for the select2 control dealing with Country.

    I’m not so conversant with JS, so was wondering how to go about…

    Thanks!
    warm regards
    Spurgeon

    #24898

    jakabadambalazs
    Participant

    Sounds good but too much hassle!

    If it is agreed that we can use the system configuration “oro_locale.country” === “Primary Location” to be set as the selected country on the oro.address.form.choose_country field when there is no data set, I’ll try to make a PR for this.

    a\


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

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

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

Back to top