Support

Account

Home Forums Backend Issues (wp-admin) Select Values not Being Saved if Select is not Displayed After Post Save Reply To: Select Values not Being Saved if Select is not Displayed After Post Save

  • Well…talk about ugly. What I did was after figuring out if it was a new post or an edit, I created a third tab and placed the selects (that I don’t want the user to see) inside the tab. I then remove the tab by means of jQuery and everything works as expected.

    If anyone has a better solution than this, please chip in. One of my selects calls an endpoint to load its values, I would love to get rid of this overhead when editing the post as that select is no longer needed. Thanks!

    		if ( PostHelper::is_current_page_new_post() ) {
    			$afb->add_adoption_type_select_field();
    			$afb->add_adoption_animal_select_field();
    			$afb->add_adoption_person_select_field();
    		} else {
    			$afb->add_adoption_type_text_field();
    			$afb->add_adoption_animal_text_field();
    			$afb->add_adoption_person_text_field();
    		}
    		$afb->add_tab_field( 'Hidden', 'hidden' );
    		if ( ! PostHelper::is_current_page_new_post() ) {
    			$afb->add_adoption_type_select_field();
    			$afb->add_adoption_animal_select_field();
    			$afb->add_adoption_person_select_field();
    		}