Dropdown Selections Not Sticking

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


Zozma

Trash Mammal

Patron

36Years Young
34 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
130 Posts

They don't think that I listen, oh but I know who they are.


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.


Check out my writing blog! All of my fanfiction and eventually my original stories are published here.



Zozma

Trash Mammal

Patron

36Years Young
34 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
130 Posts

They don't think that I listen, oh but I know who they are.


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.


Check out my writing blog! All of my fanfiction and eventually my original stories are published here.