techouse / select-auto-complete

An auto-completing Laravel Nova search field
MIT License
31 stars 17 forks source link

Hide select option value #6

Closed fouedmoussi closed 5 years ago

fouedmoussi commented 5 years ago

tempsnip

SelectAutoComplete::make('Origin market', 'origin_market') ->options(collect($mergedMarketsOptions)->mapWithKeys(function ($option) { return [$option['code'] => $option['name']]; }))->default(["value" => $this->origin_market])->displayUsingLabels()->hideFromIndex(),

Is it possible to hide option values referred to $option['code'] in the above code ?

techouse commented 5 years ago

Thanks for bringing this to my attention! Apparently the displayUsingLabels() method didn't work out of the box with vue-single-select so I fixed it in v1.1.1

bernhardh commented 4 years ago

I have made a fresh install of your package and still getting this error. I am on version v1.2.3

techouse commented 4 years ago

Hmm, what does your JSON look like?

bernhardh commented 4 years ago

For example:

{
    "component": "select-auto-complete",
    "prefixComponent": true,
    "indexName": "Darstellung (View)",
    "name": "Darstellung (View)",
    "attribute": "view_type",
    "value": "list_teaser",
    "panel": null,
    "sortable": false,
    "nullable": false,
    "readonly": false,
    "required": false,
    "textAlign": "left",
    "sortableUriKey": "view_type",
    "stacked": false,
    "bmdevClasses": {
        "editContainer": "w-1\/3"
    },
    "maxResults": 30,
    "maxHeight": "220px",
    "options": [{
        "label": "List Teaser",
        "value": "list_teaser"
    }, {
        "label": "List Teaser Klein",
        "value": "list_teaser_small"
    }, {
        "label": "Bilder-Raster",
        "value": "linked_img"
    }, {
        "label": "Titled Bottom",
        "value": "titled_bottom"
    }, {
        "label": "Teasered Bottom",
        "value": "teasered_bottom"
    }],
    "default": "list_teaser"
}

Getting this result:

image

Btw. since I am using multiple selectboxes, I also get an warning in the console:

image

techouse commented 4 years ago

Thanks for the JSON :)

So if I understand you correctly you want to display it only with labels and have used the displayUsingLabels option which should only display labels but it doesn't?

Regarding the same ids I'm not sure as to why it does that since if you look in resources/js/components/Form/index.vue on line 4 it clearly sets the id dynamically. Weird.

bernhardh commented 4 years ago

Oh. Didn't get the displayUsingLabels method, since I thought showing the label for the label would be the default behavior :D.

Thank you for your help!

techouse commented 4 years ago

Hehe, you are correct it is a bit vaguely documented. I will update the README to make it more visible.