Jump to content

Module | Select input | How to set default value from a database value ?


Recommended Posts

Hi !

I would like to find a way to set the default value of my select input, from the one saved in database. 
Because when I edit something, if i don't re-set the value of my select input it just come back to default (first value of my select input) 
Editing it everytime I want to edit something else take me time that could be save I guess. 

Thx for your Help ! 
Have a nice day


 
image.png.9949e07b73fccf9465ed8242267bf13b.png
image.png.7cd1fc3b51b3324c9ab1827099c2180e.png
image.thumb.png.5d4e6d70a70acfd63834aff64334120b.png

Link to comment
Share on other sites

if (Tools::getValue('your_id1')) {
  $select1 = dB::getInstance()->getValue('SELECT select_bg_color FROM '._DB_PREFIX_.'custom_slider_lang WHERE id_customslider_slides = '.Tools::getValue('your_id1').' AND id_lang = '.$id_lang);
  
  $this->fields_value['select_bg_color'] = $select1;
} else {
  $this->fields_value['select_bg_color'] = 'bg-new-colection-3';
}

Tools::getValue('your_id1') is your selected id_customslider_slides for edit.

$id_lang = context language id

Edited by WebSoft (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...