Venue State as Drop-down

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

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #25683

    Currently, there is no validation for state on the front-end (or admin) form when you add a venue. This means users can submit states in any format (e.g. TX, Texas, Tex-ass) and that is how it appears in the search drop-down.

    Is there a way to use a drop-down list of states instead of a text field?

    tadpole
    #25697

    Hi Dana,

    You can edit the template event-organiser-fes/templates/elements/eo-event-form-event-venue.php to use a dropdown rather than free input. (You should copy it to your theme first).

    Stephen Harris
    #25734

    Thanks, yes, I edited the form. This is what I did specifically

    <code >

     /**
       * Array of States
       *
       * @since 1.0.6
       *
       * @var array
       */
      $state_arr = array(
          'Alabama' => 'Alabama',
          'Alaska'  => 'Alaska',
          'Arizona' => 'Arizona',
          'Arkansas'    => 'Arkansas',
          'California'  => 'California',
          'Colorado'    => 'Colorado',
          'Connecticut' => 'Connecticut',
          'Delaware'    => 'Delaware',
          'District of Columbia'    => 'District of Columbia',
          'Florida' => 'Florida',
          'Georgia' => 'Georgia',
          'Hawaii'  => 'Hawaii',
          'Idaho'   => 'Idaho',
          'Illinois'    => 'Illinois',
          'Indiana' => 'Indiana',
          'Iowa'    => 'Iowa',
          'Kansas'  => 'Kansas',
          'Kentucky'    => 'Kentucky',
          'Louisiana'   => 'Louisiana',
          'Maine'   => 'Maine',
          'Maryland'    => 'Maryland',
          'Massachusetts'   => 'Massachusetts',
          'Michigan'    => 'Michigan',
          'Minnesota'   => 'Minnesota',
          'Mississippi' => 'Mississippi',
          'Missouri'    => 'Missouri',
          'Montana' => 'Montana',
          'Nebraska'    => 'Nebraska',
          'Nevada'  => 'Nevada',
          'New Hampshire'   => 'New Hampshire',
          'New Jersey'  => 'New Jersey',
          'New Mexico'  => 'New Mexico',
          'New York'    => 'New York',
          'North Carolina'  => 'North Carolina',
          'North Dakota'    => 'North Dakota',
          'Ohio'    => 'Ohio',
          'Oklahoma'    => 'Oklahoma',
          'Oregon'  => 'Oregon',
          'Pennsylvania'    => 'Pennsylvania',
          'Rhode Island'    => 'Rhode Island',
          'South Carolina'  => 'South Carolina',
          'South Dakota'    => 'South Dakota',
          'Tennessee'   => 'Tennessee',
          'Texas'   => 'Texas',
          'Utah'    => 'Utah',
          'Vermont' => 'Vermont',
          'Virginia'    => 'Virginia',
          'Washington'  => 'Washington',
          'West Virginia'   => 'West Virginia',
          'Wisconsin'   => 'Wisconsin',
          'Wyoming' => 'Wyoming',
      );
    

    <label class="eo-fes-form-element-sublabel" for="<?php $this->subfield_id( 'venue-state' ); ?>"><?php _e( 'State', 'm4bl' );?>:</label> <select id="<?php $this->subfield_id( 'venue-state' ); ?>" data-eo-venue="state" class="<?php esc_attr( $this->element->get_class() ); ?>" name="<?php echo $this->element->get_field_name( 'venue_state' ); ?>" data-eo-venue="state"> <option value="" disabled="disabled" <?php selected( esc_attr( $this->element->get_value( 'venue_state' ) ), '' ); ?>> -- <?php _e( 'Select a State' ); ?> -- </option> <?php foreach( $state_arr as $state_abbr => $state_name ) : ?> <option value="<?php echo $state_abbr; ?>" <?php selected( esc_attr( $this->element->get_value( 'venue_state' ) ), $state_abbr ); ?>><?php echo $state_name; ?></option> <?php endforeach; ?> </select>

    tadpole
Viewing 3 posts - 1 through 3 (of 3 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.