Ye as i said earlier i am using a function in beforeSave to upload the
image and set a variable to that uploaded image name.This was fine
when there was no i18n table.I used this in my other projects which
doesn't have multilanguage.But it's not working for i18n table.I am
using 'upload_image' as file field in my form and then set the
uploaded filename in 'image' field in table to be stored.Here are my
function:

In my child HowItWork model:
 function beforeSave() {

                return $this-
>upload_image('img/'.HOW_IT_WORKS_FOLDER,'image');
}

In my parent AppModel:

function upload_image($path,$field='image') {
            if( isset( $this->data[$this->alias]['upload_image'] ) ) {
                        $this->file_path=$path;
                    if(!empty($this->data[$this->alias]['prev_image']) &&
empty($this->data[$this->alias]['upload_image']['name'])){
                           $this->data[$this->alias]['upload_image']=$this-
>data[$this->alias]['prev_image'];
                           return true;
                    }

                    $this->create_folder($this->file_path);
                    $filename=$this->check_filename($this->file_path,$this-
>data[$this->alias]['upload_image']['name']);
                    $this->copy_file($this->data[$this->alias]['upload_image']
['tmp_name'], $this->file_path.$filename);
                    $this->data[$this->alias][$field]=$filename;

                    if(!empty($this->data[$this->alias]['prev_image'])){
                        $this->delete_file($path.$this->data[$this->alias]
['prev_image']);
                    }
            }
            return true;
        }

On Nov 24, 1:47 am, "Constantin.FF" <constantin...@gmail.com> wrote:
> @msujit do you use a Behavior in your attachment model to set the
> title and to create thumbs before inserting them in the database or
> everything is inside the model?
> I have tested to set a new 'title' field in me form and this title got
> inside the i18n table.
>
> On Nov 23, 5:43 pm, Constantin FF <constantin...@gmail.com> wrote:
>
>
>
>
>
>
>
> > I created new Debugtranslate Behavior just to find the reason of not
> > saving the attachment title and body in the i18n table
> > Here is the behavior
>
> > <?php
> > App::import('Behavior', 'Translate');
> > class DebugtranslateBehavior extends TranslateBehavior {
>
> >     function setup(&$Model, $settings) {
> >         if (!isset($this->__settings[$Model->alias])) {
> >             $this->__settings[$Model->alias] = array(
> >                 'fields' => array(),
> >             );
> >         }
> >         if (!is_array($settings)) {
> >             $settings = array();
> >         }
> >         $this->__settings[$Model->alias] =
> > array_merge($this->__settings[$Model->alias], $settings);
> >         //setup Translate behavior with translatable fields
> >         return parent::setup($Model,
> > $this->__settings[$Model->alias]['fields']);
> >     }
> >     function beforeSave(&$Model) {
> >                 parent::beforeSave($Model, $created);
> >         pr($Model);die;
> >         return true;
> >     }}
>
> > ?>
>
> > If the Debugtranslate behavior is attached to some ordinari model
> > saving a post I get this inside the $Model array:
>
> > Node Object
> > (
> >     [Behaviors] => BehaviorCollection Object
> >         (
> >               [Debugtranslate] => DebugtranslateBehavior Object
> >                 (
> >                     [runtime] => Array
> >                         (
> >                              [Node] => Array
> >                                 (
> >                                     [beforeSave] => Array
> >                                         (
> >                                             [title] => test
> >                                             [body] => test-node
>
> >                                         )
> >                                 )
>
> >                          )
>
> >                 )
>
> >         )
> > )
>
> > BUT when saving attachment those fields does not exists.
> > What more can I look for?
> > On Wed, Nov 23, 2011 at 2:15 PM, DigitalDude
>
> > <e.blumsten...@googlemail.com> wrote:
> > > Hey,
>
> > > @msujlt: you should always 'name' your tanslated fields, but I think
> > > cake does not force this.
> > > You then should remove the old field from the table (e.g. table
> > > attachments, field title).
>
> > > When you SAVE your racords (add/edit), you have to set the locale for
> > > your model:
> > > $this->Attachment->locale = 'eng';
>
> > > Note: I don't know what locales are defined in your app. Also, there
> > > can be differences when your locales are build like "en-gb", the
> > > locale will be "eg_gb".
> > > Try doing that, it will work but I guess you'll have to test it out
> > > with the locales of your app...
>
> > > --
> > > Our newest site for the community: CakePHP Video 
> > > Tutorialshttp://tv.cakephp.org
> > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp 
> > > others with their CakePHP related questions.
>
> > > To unsubscribe from this group, send email to
> > > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> > > athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to