Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Conversation

@davidmintz
Copy link
Contributor

@davidmintz davidmintz commented Jan 12, 2017

specifically, I have:

  • fixed references to Zend\Stdlib\Hydrator\ClassMethods
  • fixed a typo allws -> allows
  • suggested a line in the controller to set the form's action attribute to submit to itself rather setting it to the 'home' route in the viewscript
  • in the controller, wrapped the var_dump() in <pre> tags for legibility
  • fixed a syntax error in the ProductFieldset getInputerFilterSpecification() (an array was opened with the old syntax but closed with the new)
  • removed a line from the viewscript that gratuitously re-renders $this->formRow($product->get('name'));

As a side note, I was going to propose a revision to the part about not being able to submit the form with a Collection having fewer elements than it began with. I am not sure that's the case. The 'allow_remove' option seems to be just for that. But I haven't been able to prove it because at the moment I am struggling with my Doctrine and can't get it to remove entities from the N side of my 1:N.

Hope this helps :-)

specifically,  I have:

- fixed references to  Zend\Stdlib\Hydrator\ClassMethods
- fixed a typo allws -> allows
- suggested a line in the controller to set the form's action attribute to submit to itself rather setting it to the 'home'  route in the viewscript
- in the controller, wrapped the var_dump() in <pre> tags for legibility
- fixed a syntax error in the ProductFieldset getInputerFilterSpecification() (an array was opened with the old syntax but closed with the new)
- removed a line from the viewscript that gratuitously re-renders $this->formRow($product->get('name'));

As a side note, I was going to propose a revision to the part about not being able to submit the form with a Collection having fewer elements than it began with. I am not sure that's the case. The 'allow_remove' option seems to be just for that. But I haven't been able to prove it because at the moment I am struggling with my Doctrine and can't get it to remove entities from the N side of my 1:N.

Hope this helps :-)
$form->bind($product);

$request = $this->getRequest();
$form->setAttribute('action',$request->getRequestUri());
Copy link
Member

@froschdesign froschdesign Jan 12, 2017

Choose a reason for hiding this comment

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

Please remove this. The url-helper was good in the view script. The helper is used in some more examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

consistency is not always a virtue. nothing wrong with url helper per se, of course, but a route called 'home' typically maps to something like a front page, while this controller action looks like it would typically be mapped to something like '/products/add'. my purpose was simply to make the code example behave like the illustration.

Copy link
Member

Choose a reason for hiding this comment

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

Then change the name of the route to "products/add" in all examples.

Thanks!

Copy link
Contributor Author

@davidmintz davidmintz Jan 13, 2017

Choose a reason for hiding this comment

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

eh.... imho the status quo ante is preferable to that -- i.e., leave it as you had it.


if ($form->isValid()) {
var_dump($product);
echo '<pre>';
Copy link
Member

Choose a reason for hiding this comment

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

Not needed. It's a simple example and everyone knows the output or has Xdebug installed in a development environment.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fair enough. once again, the objective was to make the code act like the illustration without presupposing Xdebug or anything else.

Copy link
Member

@froschdesign froschdesign Jan 13, 2017

Choose a reason for hiding this comment

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

The documentation is not aimed at beginners and does not cover general PHP methods like var_dump. Therefore, the original code example is enough.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

indeed -- not aimed at beginners. I stand by my point but it's not a big deal, is it. I've applied all your suggestions, as noted below.

Copy link
Member

@froschdesign froschdesign Jan 13, 2017

Choose a reason for hiding this comment

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

To clarify: I mean PHP programming beginners! 😃


```php
<?php
$form->setAttribute('action', $this->url('home'));
Copy link
Member

@froschdesign froschdesign Jan 12, 2017

Choose a reason for hiding this comment

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

There is no reason to delete this. (See my comment above)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right. so, while respectfully disagreeing, I have updated my branch (fork, whatever) per your suggestions. I'm a github noob and not sure what if anything I should do next. so please let me know, if you could. thanks!

var_dump($product);
echo '<pre>';
var_dump($product);
echo '</pre>';
Copy link
Member

Choose a reason for hiding this comment

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

The same here.

@akrabat akrabat merged commit f9ee243 into zendframework:master Feb 23, 2017
akrabat added a commit that referenced this pull request Feb 23, 2017
fix mistakes, suggest improvements in collections.md
akrabat added a commit that referenced this pull request Feb 23, 2017
@akrabat akrabat assigned akrabat and unassigned akrabat Feb 23, 2017
@akrabat akrabat added this to the 2.10.0 milestone Feb 23, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants