Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiselect: selected values are not shown without placeholder #868

Closed
sandanat opened this issue Jan 19, 2021 · 2 comments
Closed

Multiselect: selected values are not shown without placeholder #868

sandanat opened this issue Jan 19, 2021 · 2 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working vue2
Milestone

Comments

@sandanat
Copy link

Selected values for multiselect are not shown when placeholder prop is not specified

Primevue: v2.3.0

  1. Open example
  2. Select values for multiselect
  3. Identify selected values are not shown
  4. Specify placeholder
  5. Selected values are shown

Selected values must be visible without placeholder specified

@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label Jan 20, 2021
@cagataycivici cagataycivici added this to the 2.3.1 milestone Jan 20, 2021
@cagataycivici
Copy link
Member

It works on v3 so we'll check for v2.

@Mohammad-Ravand
Copy link

Mohammad-Ravand commented Dec 1, 2023

i have this problem too, i cant preselect some options in multiselect
`<script setup>
import { useForm } from '@inertiajs/vue3';
import { ref, computed } from 'vue';

import MultiSelect from 'primevue/multiSelect'

const props = defineProps({
categories: {
type: Array,
required: true
},
post: {
type: Object,
required: true
}
});

const categoryOptions = computed(() => {
return props.categories.map(category => ({ name: category.name, code: category.id }))
});

const selectedCategories = computed(() => {
let r = props.post.categories.map(selectedCategory => {
selectedCategory = JSON.parse(JSON.stringify(selectedCategory))
let t= props.categories.find(cat => {
return cat.id == selectedCategory.id;
});

    return {label:'mohammad',code:t.id}
});

return r;

});

const form = useForm({
title: props.post.title ?? '',
description: props.post.description ?? '',
categories: selectedCategories.value,
image: null
});

const submit = () => {
form
.transform((data) => ({
...data,
image: data.image[0],
categories: data.categories.map(category => category.code)
}))
.post(route('post.store'), {
onFinish: () => {

        }
    });

};

</script> < `

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working vue2
Projects
None yet
Development

No branches or pull requests

4 participants