Dropdown Selections Not Sticking

Started by Zozma at Apr 11, 2021 at 7:03 pm
372 Views
4 Posts


Zozma

Trash Mammal

Client

37Years Young
41 Posts

Hey, so when I try to make a profile field that uses the selection/dropdown choice for a character, it automatically goes back to blank whenever I make any edits afterward on the character.


user posted image user posted image



Arceus

codemancer

Admin

31Years Young
135 Posts

Just because you lost me as a friend, doesn't mean you gained me as an enemy. I'm bigger than that. I still want to see you eat, just not at my table.


In this instance, it'd be either the $page->edit information isn't loading the selection properly, or the template isn't set up to display it properly. You'd need something like this in characters.template.php's template_manage():

                                          if($field->type == 1)
                                          {
                                                echo '
                                                <select name="fields[',$field->key,']" id="field',$field->id,'" class="form_control">
                                                      <option value=""></option>';
                                                      
                                                      foreach($field->options as $opt)
                                                      {
                                                            echo '
                                                            <option',(!empty($page->edit->fields[$field->key]) && $page->edit->fields[$field->key] == $opt ? ' selected' : ''),'>',$opt,'</option>';
                                                      }
                                                      
                                                echo '
                                                </select>';
                                          }

This is the part of it that controls how drop-downs are displayed, and marks them selected where applicable (it is not the whole thing so if you are missing this bit I can give you the whole thing). If this bit of code is still in-tact then most likely there's an issue loading the fields as Vesta expects.


Honey you can't dilute a war crime.

Check out my writing blog! All of my fanfiction and eventually my original stories are published here.
I also have a YouTube channel, where I post Sims videos.



Zozma

Trash Mammal

Client

37Years Young
41 Posts

The code is there! I’ll check to see if it’s something else not jiving with it. 


user posted image user posted image



Arceus

codemancer

Admin

31Years Young
135 Posts

Just because you lost me as a friend, doesn't mean you gained me as an enemy. I'm bigger than that. I still want to see you eat, just not at my table.


You might right click > inspect element on the dropdowns to see if the selected options are marked correctly and there's just something interfering with it. Sometimes they'll be selected but not show that way.


Honey you can't dilute a war crime.

Check out my writing blog! All of my fanfiction and eventually my original stories are published here.
I also have a YouTube channel, where I post Sims videos.