Create a function in your controller:
private function filter_my_data()
{
           unset($this->data['ChartsKpi'][x]);
}

// And use it in your add/edit functions


function add() {
   if(!empty($this->data)) {
       $this->filter_my_data();
       ...........
       ........... // Save Data
   }
}

On Mon, Jul 27, 2009 at 8:51 AM, DavidH <djhollingwo...@gmail.com> wrote:

>
> Hi
>
> I'm using CakePHP 1.2.3.8166 with PHP 5.2.9 on Apache 2.10
>
> I'm hoping someone will give me a hand with what is essentially a PHP
> question as oposed to a question about CakePHP.
>
> I'm returning this data array from my add.ctp view:
>
> Array
> (
>    [Chart] => Array
>        (
>            [title] => Test Chart
>            [chart_type_id] => 1
>            [width] => 128
>            [height] => 128
>        )
>
>    [ChartsKpi] => Array
>        (
>            [1] => Array
>                (
>                    [kpi_id] => 1
>                    [kpi_colour_id] => 2
>                    [width] => 5
>                )
>            [2] => Array
>                (
>                    [kpi_id] => 2
>                    [kpi_colour_id] => 3
>                    [width] => 5
>                )
>            [3] => Array
>                (
>                    [kpi_id] => 0
>                    [kpi_colour_id] =>
>                    [width] =>
>                )
>            [4] => Array
>                (
>                    [kpi_id] => 0
>                    [kpi_colour_id] =>
>                    [width] =>
>                )
>            [5] => Array
>                (
>                    [kpi_id] => 0
>                    [kpi_colour_id] =>
>                    [width] =>
>                )
>            [6] => Array
>                (
>                    [kpi_id] => 0
>                    [kpi_colour_id] =>
>                    [width] =>
>                )
>            [16] => Array
>                (
>                    [kpi_id] => 0
>                    [kpi_colour_id] =>
>                    [width] =>
>                )
>            [17] => Array
>                (
>                    [kpi_id] => 0
>                    [kpi_colour_id] =>
>                    [width] =>
>                )
> .......
>        )
> )
>
> You see all the sub arrays of [ChartsKpi] that have a kpi_id == 0? I
> dont want to save those so I've a beforeSave callback in my ChartsKpi
> model and I was trying to unset($this->data['ChartsKpi'][x]); but this
> isn't working.
>
> Is there an accepted way for taking data out of $this->data before
> doing a save?
>
> Thanks
>
> David
>
> >
>


-- 
Regards,

Jaydeep Dave
Mobile: +919898456445
Email: jaydipd...@yahoo.com

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to