gpt4 book ai didi

php - Magento addField 不使用 'value'

转载 作者:行者123 更新时间:2023-12-04 05:43:29 27 4
gpt4 key购买 nike

设置自定义表单。 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());

关于php - Magento addField 不使用 'value',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10983767/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com