Sunday, August 2, 2009

possible bug in inflector with irregular plurals?

Hi to all, i've a problem with inflector.

I'm italian and i don't want to name my tables/models/controllers with
english words (for a principle of flexibility than for a real problem
with that).

So i've added some inflection to get CakePHP working with my tables.

I have a particular problem with a table named 'squadre_serie_a'. The
singular word for this term is 'squadra_serie_a', while the plural is
'squadre_serie_a'. The only thing that changes is the 'e' in the
middle of the word.

So, my situation is this:

Table: squadre_serie_a
Model: SquadraSerieA (class), squadra_serie_a.php (file)
Controller: SquadreSerieAController (class),
squadre_serie_a_controller.php (file)

First problem was to couple controller with model and tables and i've
reach with adding to the irregular plural array ($irregularPlural)
this: 'squadra_serie_a' => 'squadre_serie_a'

Then i want to add some records to the table so i've made a view with
a form helper in this way:

<?php
echo $form->create('SquadraSerieA');
echo $form->input('nome');
echo $form->end('Save the team');
?>

But i get error because the controller is not inflected right.

Looking at the form class, i've seen that controller is inflected from
the model in this way:

$options['url']['controller'] = Inflector::underscore
(Inflector::pluralize($model));

So i've added to the $irregularPlural this pair: 'SquadraSerieA' =>
'SquadreSerieA', but this seems to break the inflector; i get this

Notice (8): Undefined index: squadraseriea [CORE/cake/libs/
inflector.php, line 255]

Tests i've made:

results legend:
$model / Inflector::pluralize($model) / Inflector::underscore
(Inflector::pluralize($model))
model / inflected plural model / inflected underscore

--
adding to $irregularPlural 'squadraseriea' => 'squadreseriea' (all
lowercase)

=> results: SquadraSerieA / Squadreseriea / squadreseriea

ok plural right but the expected controller is squadre_serie_a

--
adding to $irregularPlural 'SquadraSerieA' => 'SquadreSerieA' (as
said before)

=> results: SquadraSerieA / S / s ?????

Notice with undefined index..


Can anyone help me?? It's an inflector bug?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: