Okay
  Public Ticket #2126395
Default location dropdown to "Add new location"
Closed

Comments

  • Justin started the conversation

    Hi!

    Is there a way to make the location dropdown default to the "add new location" entry on the event submission form? Some of our users are not realizing that there is an "add new location" option above the "no location" option. We'd like for them to have the option to enter in their location address, city, etc. by default when the form loads.

    Thanks!

  •  878
    Zhivko replied

    Hi,

    Add following filter in your theme functions.php file:

    add_filter('stec_builder_front_elements', function($elements) {
        $locations = \Stachethemes\Stec\Locations::get_locations_list();
        $options   = array();
        $options[] = "<optgroup label='" . esc_html__('New location', 'stec') . "'>";
        $options[] = "<option selected value='custom'>" . esc_html__('Add new location', 'stec') . "</option>";
        $options[] = "</optgroup>";
        $options[] = "<optgroup label='" . esc_html__('Locations', 'stec') . "'>";
        $options[] = "<option value=''>" . esc_html__('No location', 'stec') . "</option>";
        if ($locations) {
            foreach ($locations as $k => $v) :
                $options[] = "<option value='{$k}'>{$v}</option>";
            endforeach;
        }
        $options[]               = "</optgroup>";
        $elements['location'][0] = sprintf("<select {{params}} name='location'>%s</select>", implode(PHP_EOL, $options));
        return $elements;
    });

    Stachethemes Developer