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

Nette\Forms\Form is not Nette\Application\UI\Form but fails silently #147

Closed
MaPePeR opened this issue Mar 16, 2017 · 6 comments
Closed
Milestone

Comments

@MaPePeR
Copy link

MaPePeR commented Mar 16, 2017

  • bug report? no
  • feature request? yes
  • version: 2.4

Description

I'm just starting to learn Nette and after looking through documentation and example code i tried to setup a very simple Form. The Form rendered fine, but the onSuccess handler was never executed and it took me a very long time to figure out the problem:
I created a Nette\Forms\Form-Object instead of the Nette\Application\UI\Form-Object that i was supposed to use.
It would be great if there would be an Exception if one tries to use the Nette\Forms\Form like a Nette\Application\UI\Form. Or at least mention this pitfall in the documentation somewhere.

Thanks.

Steps To Reproduce

  1. Be very inexperienced with the Nette Framework
  2. Write code like this in your Presenter:
	public function createComponentMyForm() {
		$form = new Nette\Forms\Form;//<- This is the Problem. 
		$form->addSubmit('submit_it', "Submit!");
		$form->onSuccess[] = [$this, 'formSucceeded'];
		return $form;
	}
	
	public function formSucceeded($form, $values) {
		//This will never be called
	}
  1. Get frustated
@lucien144
Copy link

Well, I reckon it's documented pretty well... https://doc.nette.org/en/2.4/forms#toc-forms-in-presenters. But in general I have to agree with you, this is one of the most common blockers for beginners...

@Majkl578
Copy link
Contributor

This is by design unfortunately, nothing to fix here...

@f3l1x
Copy link
Member

f3l1x commented Jun 18, 2017

What about rename it to AppForm, do you think it's better?

@Majkl578
Copy link
Contributor

That would be a massive BC break with almost no added value (as this behavior is well documented). (Btw "App" in "AppForm" would duplicate the namespace it lives in and thus the class name as well - Nette\Application\UI\Form.)

@f3l1x
Copy link
Member

f3l1x commented Jun 18, 2017

@Majk578 I agree. I think we can close it.

@MaPePeR
Copy link
Author

MaPePeR commented Jun 18, 2017

Maybe you could add the hint about the two different kind of Form to the First Form-Section of the documentation as well, because that is where i started?

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

No branches or pull requests

5 participants