O_o

Don't know why, don't know how but...

this mod works.

no more error.

Thank you very much.

On 2 Dic, 15:46, Adam Royle <[EMAIL PROTECTED]> wrote:
> Is that all the code you've got in your beforeValidate function?
>
> I can't see where $validate is being modified in the above code,
> however you probably shouldn't iterate over every associated model -
> you should just iterate over the current model. eg.
>
> class AppModel extends Model {
>
>     function beforeValidate() {
>         foreach ($this->data[$this->alias] 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;
>     }
>
> }
>
> On Dec 3, 12:31 am, Ernesto <[EMAIL PROTECTED]> wrote:
>
>
>
> > The code listed above gets me an error.
>
> > It modifies the $validate array, deleting every rule related o the
> > last field.
>
> > I can't figure out where's the error
>
> > Help T_T
>
> > On 25 Nov, 15:18, Ernesto <[EMAIL PROTECTED]> wrote:
>
> > > 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 onMySQL'sfields
> > > > > types because
> > > > > the webapp i'm baking uses some differrentfieldformatthanMySQL.
> > > > > For ex:
> > > > > - Dates are "dd/mm/yyyy" instead ofMySQL'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
-~----------~----~----~----~------~----~------~--~---

Reply via email to