2013-06-13 12 views
0

http://magento.localhost.com/index.php/arithmetic/adminhtml_arithmetic/edit/id/5/key/c03c12d4c338a2e4cdbb93c3d9e511a93401d19b21a13ea77cffda20cac94577/如何選擇在Magento

的編輯網格區域的多個複選框,這是我的鏈接是什麼樣子。我在編輯網格頁面獲得所有的值,在編輯網格頁面

有一個用於多個複選框的部分。我如何可以選擇所有的複選框根據結果排列

$fieldset-> addField('st_user_interest', 'checkboxes', array(
     'label'  => Mage::helper('arithmetic')->__('Interest'), 

     'required' => true, 
     'name'  => 'st_user_interest[]', 
    'values' => array(

     array(
      'label'  => Mage::helper('arithmetic')->__('Education'), 
      'value'  => 'education', 
     'class'  => 'required-one', 

     ), 
     array(
      'label'  => Mage::helper('arithmetic')->__('Business'), 
      'value'  => 'business', 
      'class'  => 'required-one', 

     ), 
     array(
      'label'  => Mage::helper('arithmetic')->__('Marketing'), 
      'value'  => 'marketing', 
     'class'  => 'required-one', 

     ), 

     array(
      'value'  => 'investment', 
      'label'  => Mage::helper('arithmetic')->__('Investment'), 
     'class'  => 'required-one', 
     ) 
     ),  

    )); 

感謝

+0

嗨任何一個有關於任何想法感謝 –

+0

@Shatir嗨,你有這個問題 –

回答

0

喜在存儲陣列的字段值,我們轉換數組的字符串後作爲字符串存儲的時間,

所以()Magento尋找與數組相同的輸入字段值來檢查複選框

特技是將存儲的字符串值轉換爲數組並將其分配給將要工作的列字段

Package_Arithmetic_Block_Adminhtml_Arithmetic_Edit_Tab_Form

protected function _prepareForm() 
{ 

$id = $this->htmlEscape(Mage::registry('arithmetic_data')->getIn_user_id()); 
$model = Mage::getModel("arithmeti/newuser")->load($id); 

/* here is the stuff witch converting the stored string to array and set in       st_user_interest */ 
$interest = $model->getSt_user_interest(); 
$model->setSt_user_interest(explode(',',$interest)); 


    $form = new Varien_Data_Form(); 
    $this->setForm($form); 
    $fieldset = $form->addFieldset('arithmetic_form', array('legend'=>Mage::helper('arithmetic')->__('User information'))); 


    $fieldset-> addField('st_user_interest', 'checkboxes', array(
    'label'  => Mage::helper('arithmetic')->__('Interest'), 

    'required' => true, 
    'name'  => 'st_user_interest[]', 
'values' => array(

    array(
     'label'  => Mage::helper('arithmetic')->__('Education'), 
     'value'  => 'education', 


    ), 
    array(
     'label'  => Mage::helper('arithmetic')->__('Business'), 
     'value'  => 'business', 


    ), 
    array(
     'label'  => Mage::helper('arithmetic')->__('Marketing'), 
     'value'  => 'marketing', 


    ), 

    array(
     'value'  => 'investment', 
     'label'  => Mage::helper('arithmetic')->__('Investment'), 

    ) 
    ),  

)); 

if (Mage::getSingleton('adminhtml/session')->getArithmeticData()) 
    { 

     $form->setValues(Mage::getSingleton('adminhtml/session')->getArithmeticData()); 
     Mage::getSingleton('adminhtml/session')->setArithmeticData(null); 
    } elseif ($model->getData()) { 


    //Mage::registry('arithmetic_data')->getData(); /* removing this line and adding $model->getData() inslde the $form->setValues() */ 
     $form->setValues($model->getData()); 

    } 


    return parent::_prepareForm(); 

} 
+0

@ R,S任何想法喜檢查出的答案 –