Re: Associated models in paginate results...

2009-10-20 Thread ilcaduceo

Yeah recursive was the problem! Thanks for solution, now i have
resolved... Bye!

On 20 Ott, 17:46, Céryl  wrote:
> Try using recursive = 1, I think recursive = 0 specifically only finds
> properties itself. recursive = 1 lets the model go one iteration
> deeper and also get the associated images
>
> On 20 okt, 17:18, ilcaduceo  wrote:
>
> > Hi, I have two models
>
> > Properties HasMany Images
> > Images BelongsTo Properties
>
> > In the index controller method I have this code:
>
> > $this->Property->recursive = 0;
> > $this->set('properties', $this->paginate(null, $filters));
>
> > But in the array $properties, result of paginate in the view, there
> > aren't associated model Image...
>
> > How can I have the same effect of: this->Property->find('all'); ?
>
> > Thanks and sorry for my english ;)
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Associated models in paginate results...

2009-10-20 Thread ilcaduceo

Hi, I have two models

Properties HasMany Images
Images BelongsTo Properties

In the index controller method I have this code:

$this->Property->recursive = 0;
$this->set('properties', $this->paginate(null, $filters));

But in the array $properties, result of paginate in the view, there
aren't associated model Image...

How can I have the same effect of: this->Property->find('all'); ?

Thanks and sorry for my english ;)

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: saveAll Problem

2009-10-16 Thread ilcaduceo

I've found an error in the model associations, thanks for give me
inspiration ;)

On 16 Ott, 23:31, ilcaduceo  wrote:
> This is the output:
>
> Array
> (
>     [Property] => Array
>         (
>             [title] => lorem ipsum
>             [descrizione] => Lorem ipsum dolor sit amet...
>             [prezzo] => 50
>             [metratura] => 120
>             [affitto] => 0
>             [zones_id] => 2
>             [types_id] => 2
>         )
>
>     [Image] => Array
>         (
>             [0] => Array
>                 (
>                     [nomeFile] => lorempisum
>                 )
>
>             [1] => Array
>                 (
>                     [nomeFile] => loremipsum
>                 )
>
>         )
>
> )
>
> What's wrong?
>
> On 16 Ott, 22:21, "Edinei L. Cipriani"  wrote:
>
> > Please, debug($this->data);
>
> > 2009/10/16 ilcaduceo 
>
> > > I have a problem with the saveAll function. There are two models,
> > > Property and Images:
>
> > > Property HasMany Image
> > > Image belongTo Property
>
> > > Also I have this form:
>
> > > --
> > > 
>
> > > create('Property', array('type' => 'file'));?>
> > >        
> > >                
> > >         > >                echo $form->input('Property.title');
> > >                echo $form->input('Property.descrizione');
> > >                echo $form->input('Property.prezzo');
> > >                echo $form->input('Property.metratura');
> > >                echo $form->input('Property.affitto');
> > >                echo $form->input('Property.zones_id');
> > >                echo $form->input('Property.types_id');
>
> > >                echo $form->input('Image.0.nomeFile');
> > >                echo $form->input('Image.1.nomeFile');
> > >        ?>
> > >        
>
> > > end('Salva'); ?>
> > > 
>
> > > ---
>
> > > and this is the action method in my controller:
>
> > > --
> > > function add() {
>
> > >                if (!empty($this->data)) {
> > >                        $this->Property->create();
>
> > >                        if ($this->Property->saveAll($this->data, array
> > > ('validate'=>'first')) {
> > >                                $this->Session->setFlash(__('The Property
> > > has been saved', true));
> > >                                $this->redirect(array('action'=>'add'));
> > >                        } else {
> > >                                $this->Session->setFlash(__('The Property
> > > could not be saved.
> > > Please, try again.', true));
> > >                        }
> > >                }
> > >                $zones = $this->Property->Zone->find('list');
> > >                $types = $this->Property->Type->find('list');
> > >                $this->set(compact('zones', 'types'));
> > >        }
>
> > > --
>
> > > Now the result is that the Property model is saved but the related
> > > model Image is not saved. Why? I have checked the array sintax and it
> > > is correct, also i've checked the Model Fields and they are correct.
>
> > > Can someone help me? Thak you...
>
> > --
> > Edinei L. Cipriani
> > Desenvolvedor Colégio Trilingue Inovaçãowww.colegioinovacao.com.br
> > Cursando Sistemas de Informação  - Unoesc Chapecó 1 Período
> > Integrante do grupo Fool N Lost de algoritimos computacionais
> > Fone 49 84149086
>
>
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: saveAll Problem

2009-10-16 Thread ilcaduceo

This is the output:

Array
(
[Property] => Array
(
[title] => lorem ipsum
[descrizione] => Lorem ipsum dolor sit amet...
[prezzo] => 50
[metratura] => 120
[affitto] => 0
[zones_id] => 2
[types_id] => 2
)

[Image] => Array
(
[0] => Array
(
[nomeFile] => lorempisum
)

[1] => Array
(
[nomeFile] => loremipsum
)

)

)

What's wrong?


On 16 Ott, 22:21, "Edinei L. Cipriani"  wrote:
> Please, debug($this->data);
>
> 2009/10/16 ilcaduceo 
>
>
>
>
>
> > I have a problem with the saveAll function. There are two models,
> > Property and Images:
>
> > Property HasMany Image
> > Image belongTo Property
>
> > Also I have this form:
>
> > --
> > 
>
> > create('Property', array('type' => 'file'));?>
> >        
> >                
> >         >                echo $form->input('Property.title');
> >                echo $form->input('Property.descrizione');
> >                echo $form->input('Property.prezzo');
> >                echo $form->input('Property.metratura');
> >                echo $form->input('Property.affitto');
> >                echo $form->input('Property.zones_id');
> >                echo $form->input('Property.types_id');
>
> >                echo $form->input('Image.0.nomeFile');
> >                echo $form->input('Image.1.nomeFile');
> >        ?>
> >        
>
> > end('Salva'); ?>
> > 
>
> > ---
>
> > and this is the action method in my controller:
>
> > --
> > function add() {
>
> >                if (!empty($this->data)) {
> >                        $this->Property->create();
>
> >                        if ($this->Property->saveAll($this->data, array
> > ('validate'=>'first')) {
> >                                $this->Session->setFlash(__('The Property
> > has been saved', true));
> >                                $this->redirect(array('action'=>'add'));
> >                        } else {
> >                                $this->Session->setFlash(__('The Property
> > could not be saved.
> > Please, try again.', true));
> >                        }
> >                }
> >                $zones = $this->Property->Zone->find('list');
> >                $types = $this->Property->Type->find('list');
> >                $this->set(compact('zones', 'types'));
> >        }
>
> > --
>
> > Now the result is that the Property model is saved but the related
> > model Image is not saved. Why? I have checked the array sintax and it
> > is correct, also i've checked the Model Fields and they are correct.
>
> > Can someone help me? Thak you...
>
> --
> Edinei L. Cipriani
> Desenvolvedor Colégio Trilingue Inovaçãowww.colegioinovacao.com.br
> Cursando Sistemas de Informação  - Unoesc Chapecó 1 Período
> Integrante do grupo Fool N Lost de algoritimos computacionais
> Fone 49 84149086
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



saveAll Problem

2009-10-16 Thread ilcaduceo

I have a problem with the saveAll function. There are two models,
Property and Images:

Property HasMany Image
Image belongTo Property

Also I have this form:
--


create('Property', array('type' => 'file'));?>


input('Property.title');
echo $form->input('Property.descrizione');
echo $form->input('Property.prezzo');
echo $form->input('Property.metratura');
echo $form->input('Property.affitto');
echo $form->input('Property.zones_id');
echo $form->input('Property.types_id');

echo $form->input('Image.0.nomeFile');
echo $form->input('Image.1.nomeFile');
?>


end('Salva'); ?>

---

and this is the action method in my controller:
--
function add() {

if (!empty($this->data)) {
$this->Property->create();

if ($this->Property->saveAll($this->data, array
('validate'=>'first')) {
$this->Session->setFlash(__('The Property has 
been saved', true));
$this->redirect(array('action'=>'add'));
} else {
$this->Session->setFlash(__('The Property could 
not be saved.
Please, try again.', true));
}
}
$zones = $this->Property->Zone->find('list');
$types = $this->Property->Type->find('list');
$this->set(compact('zones', 'types'));
}

--

Now the result is that the Property model is saved but the related
model Image is not saved. Why? I have checked the array sintax and it
is correct, also i've checked the Model Fields and they are correct.

Can someone help me? Thak you...

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---