Skip to content

fixes passing string arguments to tab/section visibility methods #96

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Services/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ public function labels(bool $labels): self

public function sectionVisibility($fields, bool $hidden): self
{
Collection::wrap(is_string($fields) ? func_get_args() : $fields)
Copy link
Member Author

@vmcvlad vmcvlad Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if $fields is a string, func_get_args() returns an array containing [$fields, $hidden]

Collection::wrap(is_string($fields) ? [$fields] : $fields)
->each(fn ($field) => $this->section($field)->put('hidden', $hidden));

return $this;
}

public function tabVisibility($tabs, bool $hidden): self
{
$tabs = Collection::wrap(is_string($tabs) ? func_get_args() : $tabs);
$tabs = Collection::wrap(is_string($tabs) ? [$tabs] : $tabs);

$this->template->get('sections')->each(fn ($section) => $tabs->when(
$tabs->contains($section->get('tab')),
Copy link
Member Author

@vmcvlad vmcvlad Sep 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if a collection contains true, the ->contains() method will always return true since that's how php works when doing loose comparisons ( see above comment and below picture )

image

Expand Down