This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 3

Drop down must show labels but enter different data in the database


  1. JerryH
    Member

    I need to find a way to have the list in a drop down show labels (Arizona, California, etc.) but enter different data in the database (AZ, CA, etc.).

    The users need an easy to pick description but the database requires a 2 digit code.

    Can this be done?

    Posted 12 years ago #
  2. yuniar

    Using the general dropdown field, I'm afraid it won't be possible to do so.
    However, if you are using the Address field (which contain the State field), it is possible to modify the State dropdown to do what you need.

    You can modify "includes/view-functions.php" file. Search around line 3151 and you'll find these lines:

    $state_list[0]['value'] = 'Alabama';
    $state_list[1]['value'] = 'Alaska';
    $state_list[2]['value'] = 'Arizona';
    $state_list[3]['value'] = 'Arkansas';
    $state_list[4]['value'] = 'California';

    Simply modify the above with the state codes.


    MachForm Founder

    Posted 12 years ago #
  3. JerryH
    Member

    OK, that helps but I am still not there 100%.

    I sucessfully switched my form to use the Address field and customized the State labels and values the way I need them BUT....
    I NEED the State drop down AND I NEED the Country drop down.

    Right now, I have to select "Restrict to US" to get the State drop down which eliminates all countries but US.

    Is there a way around this?
    Thanks.

    Posted 12 years ago #
  4. yuniar

    Ok, you can keep the "Restrict to US State Selection" enabled. Then modify your "includes/view-functions.php" file around line 3305:

    //if this address field is restricted to US only
    if(empty($element->is_design_mode) && !empty($element->address_us_only)){
    	$country_markup = '<option selected="selected" value="United States">United States</option>';
    }

    you can remove that block of code. This would display the complete country list and yet still display the US states as well.


    MachForm Founder

    Posted 12 years ago #

RSS feed for this topic

Reply