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

GET form throws type error on rendering #218

Closed
jtojnar opened this issue May 10, 2019 · 1 comment · Fixed by nette/forms#222
Closed

GET form throws type error on rendering #218

jtojnar opened this issue May 10, 2019 · 1 comment · Fixed by nette/forms#222

Comments

@jtojnar
Copy link

jtojnar commented May 10, 2019

Version: 3.0.0

After I updated to Nette 3, the GET forms no longer render.

You can reproduce it easily by minor tweak of the test:

--- a/tests/UI/Form.phpt
+++ b/tests/UI/Form.phpt
@@ -22,4 +22,6 @@
 	$presenter = new TestPresenter;
 	$form = new UI\Form($presenter, 'name');
 	$form->setMethod($form::GET); // must not throw exception
+
+	Assert::contains('<form', (string) $form);
 });

Running the test produces the following type error with PHP 7.2.18:

-- FAILED: Nette\Application\UI\Form | Form.phpt
   Exited with error code 255 (expected 0)
   E_USER_ERROR: Exception in Nette\Forms\Form::__toString(): parse_url() expects parameter 1 to be string, object given in /home/jtojnar/Projects/nette-application/vendor/nette/forms/src/Forms/Rendering/DefaultFormRenderer.php:170
   
   in src/Forms/Form.php(625) 
   in src/Forms/Form.php(625) trigger_error()
   in tests/UI/Form.phpt(26) Nette\Forms\Form->__toString()
   in nette-application/tests/bootstrap.php(27) {closure}()
   in tests/UI/Form.phpt(27) test()

It is weird, as the relevant code did not change in recent history:

https://github.com/nette/forms/blame/v3.0.0/src/Forms/Rendering/DefaultFormRenderer.php#L170
https://github.com/nette/application/blame/v3.0.0/src/Application/UI/Form.php#L45

@jtojnar jtojnar changed the title parse_url() expects parameter 1 to be string, object given GET form throws type error on rendering May 10, 2019
@jtojnar
Copy link
Author

jtojnar commented May 10, 2019

I am proposing one possible solution in nette/forms#222

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 a pull request may close this issue.

1 participant