Support

Home Forums Event Espresso Premium EE3: Different option value in drop down questions

EE3: Different option value in drop down questions

Posted: May 19, 2015 at 11:55 am

Viewing 3 reply threads


Antonie Geerts

May 19, 2015 at 11:55 am

Hi Guys,

I want to know how I can change the option value for the dropdown questions.

At the moment it’s coming out like this:

<option value=”Cork”> Cork</option>

I want it to come out like this

<option value=”CK”> Cork</option>

So the user will still see the correct County but the DB will store the CK entry.


Lorenzo Orlando Caum

  • Support Staff

May 19, 2015 at 12:48 pm

Hi Antonie, that is part of the core plugin and can’t currently be changed at this time.

Is this related to payment processing as in creating a new payment gateway for Event Espresso 3?


Lorenzo


Antonie Geerts

May 19, 2015 at 1:02 pm

Hi Lorenzo,

It’s for an SAP integration, I’ve been digging in the code and it seems that the “form_build.php” is generating this.

case "DROPDOWN" :

                        $dd_type = $question->system_name == 'state' ? 'name="state"' : 'name="DROPDOWN_' . $question->id . '"';
                        $values = explode(",", $question->response);
          
                        $answer = trim( stripslashes( str_replace( $find, $replace, $answer )));
                        $answer = htmlspecialchars( $answer, ENT_QUOTES, 'UTF-8' );

                        $form_input .= '
                        <p class="event_form_field">' . $label;
                        $form_input .= '
                                <select ' . $dd_type . ' ' . $required_title . ' class="' . $required_class . $class . '" id="DROPDOWN_' . $question->id . '"  />
                                        <option value=""></option>';

                        foreach ($values as $key => $value) {

                                $value = trim( stripslashes( str_replace( $find, $replace, $value )));
                                $value = htmlspecialchars( $value, ENT_QUOTES, 'UTF-8' );
                                $formatted = apply_filters('filter_hook_espresso_parse_question_answer_for_price',$value, $question->price_mod);
                                $selected = ( $formatted == $answer ) ? ' selected="selected"' : "";
                                $form_input .= '
                                        <option value="' . $formatted . '"' . $selected . '/> ' . $formatted . '</option>';

                        }
              

                        $form_input .= '
                                </select>';
                        $form_input .= '

If added in a extra row in the events_questions table called response-code and change to option value from $formatted to $formatted-code for example would that work?


Dean

May 20, 2015 at 3:38 am

Hi,

In theory I can’t see why it wouldn’t but I would test on a development server first and back up your database as a priority. I’d be tempted to add it to a separate custom table as updates may not be happy with the additional table column.

Please note, unless you “plug” the function (it is pluggable – https://codex.wordpress.org/Pluggable_Functions) updates will over write your changes.

Please also note that as this is a core customisation we cannot support it, so you may need to get a developer into the mix if you are struggling to get it to work.

In a lot of ways it might be easier to catch the data on it’s way to the SAP integration and simply modify the county name to code at that point – this might be safer overall rather than modifying core files.

Viewing 3 reply threads

The support post ‘EE3: Different option value in drop down questions’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso