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

Calling ->dump() on a field with sub_fields always returns error #153

Open
marcoluzi opened this issue Aug 16, 2024 · 2 comments · May be fixed by #154
Open

Calling ->dump() on a field with sub_fields always returns error #153

marcoluzi opened this issue Aug 16, 2024 · 2 comments · May be fixed by #154
Labels

Comments

@marcoluzi
Copy link

Description of the bug

Using ->dump() on a Field that has sub_fields always return the following error:

Fatal error: Uncaught Error: Call to a member function get() on array

The dump itself is returned but the error happens afterwards.

Screenshot 2024-08-16 at 14 30 56

Dumps on other fields are returned without any errors. Also tested on the Repeater field with the same resulting error as above.

Steps to reproduce

register_extended_field_group([
	'title' => 'Kundeninformationen',
	'fields' => [
		Image::make('Logo'),
		Text::make('Firmenname'),
		Text::make('Strasse/Nr.'),
		Text::make('PLZ'),
		Text::make('Ort'),
		Text::make('Telefon'),
		Group::make('Social Media')
			->fields([
				URL::make('Facebook'),
				URL::make('Instagram'),
				URL::make('LinkedIn'),
				URL::make('X'),
				URL::make('YouTube'),
			])->dump(),
	],
	'location' => [Location::where('post_type', 'page')],
]);
@vinkla
Copy link
Owner

vinkla commented Aug 19, 2024

I can confirm the issue. This occurs because we convert the sub_fields into an array within the get method. The next time it runs, the array is already converted. To address this, we could maybe clone the current field instance before processing it. Feel free to submit a pull request!

@marcoluzi
Copy link
Author

@vinkla I tested the changes in the PR using the PHPUnit tests provided in the repo. No errors were found. However, since I lack the overall picture of the tool, I would be glad to receive any feedback regarding my changes.

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

Successfully merging a pull request may close this issue.

2 participants