Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

In baked views, under related models, the "new" link should use the singular form of the model name. #173

Closed
wants to merge 2 commits into from

3 participants

@hftf

Fixed (I think?) pull request based on ADmad's comment on the corresponding ticket

http://cakephp.lighthouseapp.com/projects/42648/tickets/1902-use-singular-form-for-new-links-in-baked-views

@renan
Collaborator

If the $alias is the model $alias, so it's supposed to be singular already.

Do you have any model with an plural $alias?

@hftf

Yes, I have an EventsIntervals model that belongsTo Event. I saw a "New Events Interval" link in the views for EventsIntervals, but the link text was "New Events Intervals" under "Related Events Intervals" in the view for Event.

@ADmad
Collaborator

Well so your model name is not following convention as it doesn't end in a singular word. So its not a bug in the templates.

@hftf

Oh, then that's my mistake. But now I'm curious: why is the link text only different here (plural instead of singular)? Also, shouldn't you always inflect to the singular form, regardless of naming convention, because X is always singular in "new X"? Thanks!

@ADmad
Collaborator

No point adding extra Inflector calls. Just follow conventions. And if you can't/don't follow conventions you can always make your own bake templates and customize to your needs.

@ADmad ADmad closed this
@renan
Collaborator

The thing is: its not a bug and we can't implement features/enhancements on 1.3 releases anymore.

However, if you see the same thing happening in 2.0 while we are still developing, you could send us a pull request.

Thank you!

@hftf

Ah, if I had known I didn't follow conventions (maybe bake should warn you about that?), I wouldn't have thought this was a bug. Thanks anyway for your time!

@ADmad
Collaborator

Well the manual is pretty clear about the model naming conventions. Adding convention checks everywhere in the core isn't practical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Aug 12, 2011
  1. @hftf
  2. @hftf
This page is out of date. Refresh to see the latest.
View
2  cake/console/templates/default/views/view.ctp
@@ -139,7 +139,7 @@ echo "\t<?php endforeach; ?>\n";
<?php echo "<?php endif; ?>\n\n";?>
<div class="actions">
<ul>
- <li><?php echo "<?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore($alias)) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?> </li>
+ <li><?php echo "<?php echo \$this->Html->link(__('New " . Inflector::humanize(Inflector::underscore(Inflector::singularize($alias))) . "', true), array('controller' => '{$details['controller']}', 'action' => 'add'));?>";?> </li>
</ul>
</div>
</div>
View
2  cake/libs/view/scaffolds/view.ctp
@@ -152,7 +152,7 @@ $otherSingularVar = Inflector::variable($_alias);
<?php endif; ?>
<div class="actions">
<ul>
- <li><?php echo $this->Html->link(sprintf(__("New %s", true), Inflector::humanize(Inflector::underscore($_alias))), array('controller' => $_details['controller'], 'action' => 'add'));?> </li>
+ <li><?php echo $this->Html->link(sprintf(__("New %s", true), Inflector::humanize(Inflector::underscore(Inflector::singularize($_alias)))), array('controller' => $_details['controller'], 'action' => 'add'));?> </li>
</ul>
</div>
</div>
Something went wrong with that request. Please try again.