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

Passing additional option data to a custom form tag field vue #176

Open
atmediauk opened this issue Oct 6, 2022 · 0 comments
Open

Passing additional option data to a custom form tag field vue #176

atmediauk opened this issue Oct 6, 2022 · 0 comments

Comments

@atmediauk
Copy link

atmediauk commented Oct 6, 2022

Hello,

Thank you for adding the ability to overwrite the form tag field!

Would it be possible to pass additional option data? Specifically to use within the custom vue template? This would be really powerful. For example:

          Multiselect::make('Football teams')
            ->options([
              'liverpool' => ['label' => 'Liverpool FC', 'custom' => 'foo'],
              'tottenham' => ['label' => 'Tottenham Hotspur', 'custom' => 'bar'],
            ]),

Then referencing these in the custom Vue template:

<template>
  <span class="multiselect__tag">
    <span>{{ option.label.trim() }}</span>
    <span>{{ option.custom }}</span>
    <i class="multiselect__tag-icon" @click="remove(option)"></i>
  </span>
</template>
...

EDIT: This looks be possible with a very small change:

outl1ne/nova-multiselect-field/src/Multiselect.php

Change line 44 from

return ['label' => $key, 'values' => $value->map->only(['label', 'value'])->toArray()];

to:

return ['label' => $key, 'values' => $value->map->only(['label', 'value', 'custom'])->toArray()];

Then in the NovaResource

          Multiselect::make('Football teams')
            ->options([
              'liverpool' => ['label' => 'Liverpool FC', 'custom'=> ['description' => 'foobarbaz']],
              'tottenham' => ['label' => 'Tottenham Hotspur', 'custom'=>['description' => 'abc123']],
            ]),

and finally in FormFieldTag.vue

{{ option.custom.description }}

Hopefully its possible 🙈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant