Yeah man i almost did it :)
here's a snippet, maybe some1 else needs that code in future
class AppModel extends Model {
function beforeValidate() {
foreach ($this->data as &$model) {
foreach ($model as $fieldname => &$value) {
switch ($this->getColumnType($fieldname)) {
case "float":
$value = str_replace(",", ".",
$value);
break;
case "date":
case "datetime":
$value = data_IT_to_US($value);
break;
default:
}
}
}
return true;
}
}
Now i'm working on data_IT_to_US() (looking for a smart & easy
method) :)
On 25 Nov, 09:51, Adam Royle <[EMAIL PROTECTED]> wrote:
> I do a similar thing in my AppModel. Look at the Model methods and
> also pr($this) in your AppModel to see what data you can access, etc.
> You can get all thefieldnames and types easily using $this->schema()
> or $this->getColumnTypes().
>
> Cheers,
> Adam
>
> On Nov 25, 2:34 am, Ernesto <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hello.
>
> > My goal is to provide adefaultformatting, based on MySQL's fields
> > types because
> > the webapp i'm baking uses some differrentfieldformatthan MySQL.
> > For ex:
> > - Dates are "dd/mm/yyyy" instead of MySQL's "yyyy-mm-dd"
> > - Floating point numbers uses commas instead of dots as decimal
> > separator
>
> > I've made a FieldFormatHelper, called in every controller's
> > beforeValidate() function but that's not very handy because i need a
> > rule for everyfield.
>
> > So i tried to process fields in AppModel's beforeValidate() but i
> > can't get the code to work.
>
> > How can i do?
> > Is there a better way?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---