Skip to content

Conversation

@AleksandrSpicyn
Copy link
Contributor

This merge request introduces multiple improvements and bugfixes for the Select and Checkable field components:

Select (Former\Form\Fields\Select)

Fixed an edge case where previously selected values could persist due to missing state reset:

Added clearSelected() method to ensure no stale selected attributes remain before rendering.

Improved type-safety when comparing numeric values:

Comparison logic in selectValue() now safely handles both strings and integers using strict coercion.

Enhanced addOption() to support optgroup with nested options that include attributes (not just text).

Preserved backward compatibility by retaining existing behavior unless extra attributes are passed.

Checkable (Former\Traits\Checkable)

Restored and improved the fromQuery() method:

Now supports passing closures for $text and $attributes, consistent with Select::fromQuery().

Refactored internal items() method:

Accepts Eloquent/Fluent collections and converts them using Helpers::queryToArray().

Now matches behavior of Select, including array_flip() fallback for simpler usage.

This change enables developers to build dynamic radio() and checkbox() groups using collection-driven definitions, without requiring external transformation logic.

@claar
Copy link
Member

claar commented Jul 4, 2025

@AleksandrSpicyn Thank you for your work on this! Looks great at first glance. I haven't had a chance to test it yet, but I do notice some whitespace problems in the diff. Can you please ensure the changes match the current indentation/whitespace?

@AleksandrSpicyn
Copy link
Contributor Author

@AleksandrSpicyn Thank you for your work on this! Looks great at first glance. I haven't had a chance to test it yet, but I do notice some whitespace problems in the diff. Can you please ensure the changes match the current indentation/whitespace?

Yeah, sorry for this, updated.

@Vadim-Kunesh
Copy link

Vadim-Kunesh commented Jul 18, 2025

Seems that this pull request got lost, @claar could you please take a look at it?

@claar claar merged commit 7f2e848 into formers:master Jul 18, 2025
16 checks passed
@claar
Copy link
Member

claar commented Jul 18, 2025

Released in v5.1.1 - thanks @AleksandrSpicyn !

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

Successfully merging this pull request may close these issues.

3 participants