Skip to content
Advertisement

Laravel select tags in edit page

I cannot get assigned tags in my view as auto selected:

Logic

  1. Get all tags $tags.
  2. Get assigned tags from database $tags2.
  3. Auto select assigned tags.

Code

JavaScript

Values

$tags array of assigned tags to my model in this case 2, result

JavaScript

this two uuid should be auto selected in $tags which is is my full tags array.

Current result

one

Nothing has been selected.

Note: I am using chosen for my select input

Advertisement

Answer

try in_array()

ref link https://www.w3schools.com/php/func_array_in_array.asp

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement