开发者

Trying to edit multiple records at once, saveAll not working

I'm saving multiple Widgets and associated WidgetsItems to a menu, which I have working fine.

The problem is, my edit function is not working. I understand that the data array structure needs to be as following, as it is what is saving my data properly in the first place:

Array (
[Widget] => Array
    (
        [23] => Array
            (
                [title] => Cocktails
                [id] => 23
                [WidgetsItem] => Array
                    (
                        [147] => Array
                            (
                                [item] => Martini: Noilly Pratt, Ginor Vodka
                                [price] => 24
                                [id] => 147
                            )
                        [148] => Array
                            (
                                [item] => Negroni: Campari, Gin, Sweet Vermouth
                                [price] => 16
                                [id] => 148
                            )
                    )
            )

using the following controller code:

foreach($this->data['Widget'] as $widgetKey => $widget) : 
                $widgetData = array(
                    'title' => $widget['title'],
                    'id' => $widget['id']
                );
                $saveable开发者_StackOverflow中文版Widget = Set::insert($widget, 'Widget', $widgetData);
                if($this->Widget->saveAll($saveableWidget)) : $saveSuccess = true; endif;
            endforeach;

Which is copied and pasted from the initial save function, then modified a little for editing. Instead, it's creating new entries, not editing them. I know it's something to do with the IDs, but it's just not saving. What am I doing wrong?

Please help, I feel like I'm very close to a nearly finished product.

Thanks,

~harley

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜