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

Add fromArray to options #2163

Merged
merged 4 commits into from
Mar 10, 2023
Merged

Add fromArray to options #2163

merged 4 commits into from
Mar 10, 2023

Conversation

aksiome
Copy link
Contributor

@aksiome aksiome commented Feb 24, 2023

This PR adds a fromArray helper to the Options class and use it inside the options method.

Select::make()->name('select')->options(Options::make([
	Option::make('foo', 'bar'),
	Option::make('val', 'label', true),
	Option::make('awesome', 'twill', true),
]))

All following syntaxes are supported.

Select::make()->name('select')->options([
	'foo' => 'bar',
	[
		'value' => 'val',
		'label' => 'label',
		'selectable' => true,
	],
	Option::make('awesome', 'twill', true),
]))

@what-the-diff
Copy link

what-the-diff bot commented Feb 24, 2023

  • Changed the order of arguments in Option::make() from (key, value) to (value, label).
  • Added a new method Options::fromArray().

@codecov
Copy link

codecov bot commented Feb 24, 2023

Codecov Report

Patch coverage: 25.00% and project coverage change: -0.04 ⚠️

Comparison is base (2ccd4a7) 59.90% compared to head (920110c) 59.87%.

Additional details and impacted files
@@             Coverage Diff              @@
##                3.x    #2163      +/-   ##
============================================
- Coverage     59.90%   59.87%   -0.04%     
- Complexity     3904     3908       +4     
============================================
  Files           303      304       +1     
  Lines         15039    15049      +10     
============================================
+ Hits           9009     9010       +1     
- Misses         6030     6039       +9     
Impacted Files Coverage Δ
src/Services/Forms/Options.php 0.00% <0.00%> (ø)
src/Services/Forms/Fields/Traits/HasOptions.php 76.47% <75.00%> (-3.53%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@haringsrob
Copy link
Contributor

Hey @aksiome,

Great, if you can add a bit of docs this can go in.

aksiome and others added 3 commits March 3, 2023 17:48
@haringsrob haringsrob merged commit fc67a2d into area17:3.x Mar 10, 2023
@aksiome aksiome deleted the options-array branch March 19, 2023 15:06
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.

2 participants