在自定义模式的Magento保存多选阵 [英] Magento Saving Multiselect Array on Custom Model

查看:138
本文介绍了在自定义模式的Magento保存多选阵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已创建在Magento自定义模式,可以去和编辑在管理。我在处理阵列不过麻烦。当我去保存模型,文本字段保存很好,但多选场只是保存为'阵',我再无力去和编辑它。

I have create a custom model in Magento which can get to and edit in the admin. I'm having trouble dealing with array's however. When I go to save the model, the text field saves fine, but the multiselect field just saves as 'array' and I'm then unable to go and edit it.

我需要知道如何保存和模型中检索该阵列的数据。数据阵列,显示在多选场简单过滤的产品数据。

I need to know how to save and retrieve this array data within the model. The array of data that shows in the multiselect field in simply filtered product data.

任何人都可以在这方面帮助?任何帮助非常AP preciated!

Can anybody help with this? Any help much appreciated!!!

推荐答案

想通了 - 在你的控制器的saveAction(),这下:

Figured it out - on the saveAction() of your controller, underneath this:

$data = $this->getRequest()->getPost()

我只是添加了以下code:

I simply added the following code :

foreach ($data as $key => $value)
        {
            if (is_array($value))
            {
                $data[$key] = implode(',',$this->getRequest()->getParam($key)); 
            }
        }   

这篇关于在自定义模式的Magento保存多选阵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆