This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

Anonymous

  • ****
  • 200 posts
assign country
« on: January 19, 2018, 10:34:36 AM »
hi,
how will i assign country (fixed) in item.post  or publish page

i having dropdown country form,
am trying to assign fixed country no dropdown.


 <div class="location">
      <div class="row">
                        <label for="address"><?php _e('Country', 'veronika'); ?> <span>*</span></label>
                        <div class="select input-box">
                            <?php ItemForm::country_select(osc_get_countries(), osc_user()) ; ?>
                        </div>
                    </div>

Code: [Select]
<?php 
          $user 
osc_user();

          
$prepare = array();
        
          
$prepare['i_country'] = veronika_get_session('sCountry') <> '' ?veronika_get_session('sCountry') : osc_user_field('fk_c_country_code');
        
        
?>

Innovation is change that unlocks new value  ;)

*

MB Themes

Re: assign country
« Reply #1 on: January 19, 2018, 10:45:24 AM »
@Anonymous
You should take a look on that function in oc-includes/osclass/frm/Item.form.class.php
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Anonymous

  • ****
  • 200 posts
Re: assign country
« Reply #2 on: January 19, 2018, 10:56:16 AM »
t think thats the code-    M I Right  ???
Code: [Select]
static public function country_select($countries = null, $item = null) {
            if($countries==null) { $countries = osc_get_countries(); };
            if($item==null) { $item = osc_item(); };
            if( count($countries) >= 1 ) {
                if( Session::newInstance()->_getForm('countryId') != "" ) {
                    $item['fk_c_country_code'] = Session::newInstance()->_getForm('countryId');
                }
                parent::generic_select('countryId', $countries, 'pk_c_code', 's_name', __('Select a country...'), (isset($item['fk_c_country_code'])) ? $item['fk_c_country_code'] : null);
                return true;
            } else {
                if( Session::newInstance()->_getForm('country') != "" ) {
                    $item['s_country'] = Session::newInstance()->_getForm('country');
                }
                parent::generic_input_text('country', (isset($item['s_country'])) ? $item['s_country'] : null);
                return true;
            }
        }


but what about ajax validation
Code: [Select]
$('#region').on('keyup.autocomplete', function(){
            $('#regionId').val('');
            if($('#countryId').val()!='' && $('#countryId').val()!=undefined) {
                var country = $('#countryId').val();
            } else {
                var country = $('#country').val();
            }
            $( this ).autocomplete({
            [color=red]source: "<?php echo osc_base_url(true); ?>?page=ajax&action=location_regions&country="+country,[/color]
                minLength: 2, 
                select: function( event, ui ) {
                    $('#cityId').val('');
                    $('#city').val('');
                    $('#regionId').val(ui.item.id);
                }
            });
        });

will it affect it-

« Last Edit: January 19, 2018, 10:58:44 AM by Anonymous »
Innovation is change that unlocks new value  ;)

*

MB Themes

Re: assign country
« Reply #3 on: January 19, 2018, 11:08:39 AM »
Those are 2 different functions and features.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Anonymous

  • ****
  • 200 posts
Re: assign country
« Reply #4 on: January 19, 2018, 11:17:34 AM »
pls suggest me- doesnt seems to possible from me-
am also trying-
 $prepare['i_country'] = veronika_get_session('sCountry') <> '' ? veronika_get_session('sCountry') : osc_user_field('fk_c_country_code');
replaced into
  $prepare['i_country'] = veronika_get_session('sCountry') <> '' ? veronika_get_session('sCountry') : osc_user_country();
     
    $prepare['i_region'] = veronika_get_session('sRegion') <> '' ? veronika_get_session('sRegion') : osc_user_region_id();

nothing seems to work  :-\
am a junior developer  :D

you are a senior dev  ;)   suggest me solution please  :)
Innovation is change that unlocks new value  ;)

*

MB Themes

Re: assign country
« Reply #5 on: January 19, 2018, 11:33:17 AM »
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

Anonymous

  • ****
  • 200 posts
Re: assign country
« Reply #6 on: January 19, 2018, 06:18:54 PM »
I find the solution!
Thanks.

Solved
Innovation is change that unlocks new value  ;)

Marked as best answer by Anonymous on January 19, 2018, 06:23:37 PM
*

Anonymous

  • ****
  • 200 posts
Re: assign country
« Reply #7 on: January 19, 2018, 06:21:26 PM »
I find the solution!
Thanks.

Fetched db's appropriate value through dao!
How simple is it!  :)
Solved
« Last Edit: January 19, 2018, 06:23:22 PM by Anonymous »
Innovation is change that unlocks new value  ;)

*

timlex

Re: assign country
« Reply #8 on: December 21, 2018, 09:46:03 PM »
Hello
I need this, I've tried it many times but it doesn't work. Please suggest me more details.
« Last Edit: December 21, 2018, 09:47:58 PM by timlex »