Magento addField doesn't use 'value'


Magento addField doesn't use 'value'

设置自定义表单。 Magento不使用addField的"value"属性。 建议?

法典:

$form = new Varien_Data_Form(array(
    'id' => 'edit_form',
    'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
    'method' => 'post',
    'enctype' => 'multipart/form-data',
));
$form->setUseContainer(true);
$this->setForm($form);
$fieldset = $form->addFieldset('example_form', array(
     'legend' =>Mage::helper('categoryrules')->__('Example Information')
));
...
$entityType = Mage::getModel('eav/config')->getEntityType('test_category_rule');
$entityTypeId = $entityType->getEntityTypeId();
...
$fieldset->addField('entity_type_id', 'hidden', array(
      'name'               => 'entity_type_id',
      'value'              => $entityTypeId
));

输出:

<input id="entity_type_id" name="entity_type_id" value="" type="hidden">

编辑:

print_r($entityType->debug())的结果;

Array ( 
    [entity_type_id] => 11 
    [entity_type_code] => rogue_category_rule 
    [entity_model] => categoryrules/rules 
    [attribute_model] => 
    [entity_table] => categoryrules/rules 
    [value_table_prefix] => 
    [entity_id_field] => 
    [is_data_sharing] => 1 
    [data_sharing_key] => default 
    [default_attribute_set_id] => 0 
    [increment_model] => 
    [increment_per_store] => 0 
    [increment_pad_length] => 8 
    [increment_pad_char] => 0 
    [additional_attribute_table] => 
    [entity_attribute_collection] => 
)

尝试在这里写任何常量,例如:

$fieldset->addField('entity_type_id', 'hidden', array(
      'name'               => 'entity_type_id',
      'value'              => 11
));

或:

$fieldset->addField('entity_type_id', 'hidden', array(
      'name'               => 'entity_type_id'
));
$form->setValues($entityType->getData());