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

Pls help with select multiple #705

Open
tm-blg opened this issue Nov 20, 2024 · 5 comments
Open

Pls help with select multiple #705

tm-blg opened this issue Nov 20, 2024 · 5 comments

Comments

@tm-blg
Copy link

tm-blg commented Nov 20, 2024

Discussed in #666

Originally posted by tm-blg November 13, 2024
Hi, there! I'm trying to save array into model

<flux:select wire:model.live="var.product_kinds" variant="listbox" multiple placeholder="Choose industries...">
        <flux:option>bulb</flux:option>
        <flux:option>partnumber</flux:option>
        <flux:option>projector</flux:option>
</flux:select>
#[Validate([
    'var.product_kinds' => 'array|nullable',
])]
public Feature $var;

public function mount()
{
    $this->var = new Feature();
}

Where i choose more than two option, i get LogicException "Something went wrong"

image
image

@tm-blg
Copy link
Author

tm-blg commented Nov 20, 2024

finally I found a solution.

This exception occurs either because of incorrectly specified casts.
In my case specifically it was incorrect validation. U just need add validation rule for everyone checkbox like this:

public function rules()
  {
      return [
          **'test.one.*' => 'string|nullable',**
          'test.one' => 'array|nullable',
    ]

@tm-blg
Copy link
Author

tm-blg commented Nov 20, 2024

In Livewire2 we dont need to do anything, all is work. is it possible to at least create some kind of comparison of versions and principles of work, so as not to mislead fans of livewire. It seemed logical to me to validate only the array.

@ju5t
Copy link

ju5t commented Nov 20, 2024

Arguably, questions should be posted in discussions; this is not a Flux issue.

@tm-blg
Copy link
Author

tm-blg commented Nov 21, 2024

@tm-blg See:

dear, it's not like I read all the documentation three times, I also rewatched Caleb's video courses.

your links don't have any info on such a small detail. you couldn't figure it out last time, remember?

Okay, forget it, I'm very emotional because I spent a lot of effort. Thanks everyone, bye!

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

3 participants