English 中文(简体)
Magento adminhtml 窗体字段未添加到 POST 中
原标题:Magento adminhtml form fields not adding to POST
  • 时间:2012-05-25 10:15:32
  •  标签:
  • php
  • magento

我有以下田地 以magento adminhtml形式。

"https://i.sstatic.net/wL6I2.png" alt="我形式的字段"/"

面对我期待的 抓住这个职位, 简单地抛弃它的内容, 在我的拯救行动中这样做。

public function saveAction()
{
    if ($this->getRequest()->getPost())
    {
        try{
            $postData = $this->getRequest()->getPost();
            echo  <pre> ;
            print_r($postData);
            exit;

输出结果如下。

Array
(
    [form_key] => I6jK6swe1EMl0wER
    [carrier_code] => test
    [postcode] => tescode
    [sku] => 123445
)

看我的表情被定义为:

$form = new Varien_Data_Form();
$this->setForm($form);
$fieldset = $form->addFieldset( instance_form , array( legend =>Mage::helper( instance )->__( Instance Filters )));

    $fieldset->addField( carrier_code ,  text , array(
             label      => Mage::helper( instance )->__( Carrier service ),
             name       =>  carrier_code ,
             after_element_html  =>  <small>Leave blank for all Carriers.</small> ,
    ));
    
    $fieldset->addField( postcode ,  text , array(
             label      => Mage::helper( instance )->__( Postcode ),
             name       =>  postcode ,
             after_element_html  =>  <small>Leave blank for all Postcodes.</small> ,
    ));
    
    $fieldset->addField( sku ,  text , array(
             label      => Mage::helper( instance )->__( Sku ),
             name       =>  sku ,
             after_element_html  =>  <small>Leave blank for all Skus.</small> ,
    ));
    
    $fieldset->addField( start_date ,  date , array(
             label      => Mage::helper( instance )->__( Start Date ),
             after_element_html  =>  <small>Comments</small> ,
             tabindex  => 1,
             image  => $this->getSkinUrl( images/grid-cal.gif ),
             format  => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT)
    ));
    
    $fieldset->addField( aura ,  file , array(
             label      => Mage::helper( instance )->__( Upload ),
             value   =>  Uplaod ,
             disabled  => false,
             readonly  => true,
             after_element_html  =>  <small>Comments</small> ,
             tabindex  => 1
    ));

我期待看到这样的产出:

Array
(
    [form_key] => I6jK6swe1EMl0wER
    [carrier_code] => test
    [postcode] => tescode
    [sku] => 123445
    [start_date] => someValue
    [aura] => anotherValue

)

我漏掉了什么? 为什么会说日期字段, 而不是添加到该文章中, 像所有其他文本输入字段一样?

干杯 干杯

最佳回答

您在您的 < code> name 调用中再次丢失了 < code> name 密钥。 < code> addd Field( start_ date,.) 调用 。

您想要提交的 Varien_Data_Form 的每个字段都需要 name key/value 配对。

您指定给字段 s name 键的值被用作相应的 name 属性的数值 元素生成 时的数值。

问题回答

暂无回答




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...