• Hi, may I know how can I edit the templates (location.php & where.php) if I want to create a dropdown list in State field (when physical location is selected). User can choose from the list of states when filling out event/location form.

    templates > forms > event > location.php

    and

    templates > forms > location > where.php

    Regards.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Add the following code snippet:

    function em_get_states() {
        return array('AL' => 'Alabama','AK' => 'Alaska','AZ' => 'Arizona','AR' => 'Arkansas','CA' => 'California','CO' => 'Colorado', 'CT' => 'Connecticut','DE' => 'Delaware','DC' => 'Washington DC','FL' => 'Florida','GA' => 'Georgia','HI' => 'Hawaii','ID' => 'Idaho','IL' => 'Illinois','IN' => 'Indiana','IA' => 'Iowa','KS' => 'Kansas','KY' => 'Kentucky','LA' => 'Louisiana','ME' => 'Maine','MD' => 'Maryland','MA' => 'Massachusetts','MI' => 'Michigan','MN' => 'Minnesota','MS' => 'Mississippi','MO' => 'Missouri','MT' => 'Montana','NE' => 'Nebraska','NV' => 'Nevada','NH' => 'New Hampshire','NJ' => 'New Jersey','NM' => 'New Mexico','NY' => 'New York','NC' => 'North Carolina','ND' => 'North Dakota','OH' => 'Ohio','OK' => 'Oklahoma','OR' => 'Oregon','PA' => 'Pennsylvania','RI' => 'Rhode Island','SC' => 'South Carolina','SD' => 'South Dakota','TN' => 'Tennessee','TXTexas' => '','UT' => 'Utah','VT' => 'Vermont','VA' => 'Virginia','WA' => 'Washington','WV' => 'West Virginia','WI' => 'Wisconsin','WY' => 'Wyoming');
    }
    

    Then replace the following in templates > forms > event > location.php and in templates > forms > location > where.php

                    <input id="location-state" type="text" name="location_state" value="<?php echo esc_attr($EM_Location->location_state); ?>" >

    With this:

                    <select id="location-state" name="location_state" class="em-selectize">
                        <?php foreach(em_get_states() as $state_key => $state_name): ?>
                        <option value="<?php echo esc_attr($state_key); ?>" <?php echo ( $EM_Location->location_state == $state_key) ? 'selected="selected"':''; ?>><?php echo esc_html($state_name); ?></option>
                        <?php endforeach; ?>
                    </select>
    Thread Starter enkoes

    (@enkoes)

    Thanks. It works beautifully!

    Sorry for writing in another user’s topic, but I think the question is appropriate here. joneiseman, as you advised me in another message, it is better to change the code in templates in other folders. And in this case, do we change it directly in the source code? I want to remove a couple of fields from where.php, should I do it right here, or make a copy to another place and change it there?

    You need to make a copy and change it there. Create the directory wp-contents/plugin-templates/events-manager/forms/location and then copy wp-contents/plugins/events-manager/templates/forms/location/where.php to this new directory and then modify it in the new location.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Dropdown list in state field’ is closed to new replies.