Home Forums Porto Admin Template Select2

This topic contains 1 reply, has 2 voices, and was last updated by  Support2 2 weeks ago. This post has been viewed 51 times

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #10027570

    KamilCwiertnia
    Participant

    Hi. I use select2 plugin in option multiple. From the list of available items I would like to select the default several values ​​that will be retrieved from the database. How could I solve this?


    #10027571

    Support2
    Keymaster

    Hello,

    You must return the select options from database with the selected attribute. For example:

    <select multiple data-plugin-selectTwo class="form-control populate" lang="es">
    	<optgroup label="Alaskan/Hawaiian Time Zone">
    		<option value="AK" selected>Alaska</option>
    		<option value="HI" selected>Hawaii</option>
    	</optgroup>
    	<optgroup label="Pacific Time Zone">
    		<option value="CA">California</option>
    		<option value="NV">Nevada</option>
    		<option value="OR" selected>Oregon</option>
    		<option value="WA">Washington</option>
    	</optgroup>
    	<optgroup label="Mountain Time Zone">
    		<option value="AZ">Arizona</option>
    		<option value="CO">Colorado</option>
    		<option value="ID">Idaho</option>
    		<option value="MT">Montana</option>
    		<option value="NE">Nebraska</option>
    		<option value="NM">New Mexico</option>
    		<option value="ND">North Dakota</option>
    		<option value="UT">Utah</option>
    		<option value="WY">Wyoming</option>
    	</optgroup>
    </select>

    * Note the selected.

    Please, try that and let us know if you need further assistance.

    Kind Regards,

    Rodrigo.


Viewing 2 posts - 1 through 2 (of 2 total)