Answers:
尝试这个:
<depends>
<field separator="|">
<value>1|2|3</value>
</field>
</depends>
$dependent['separator']
返回属性的值separator
。向曾对此表示反对的人,请进行投票(如果可能,请两次)。完美运作。谢谢。cc @benmarks
[编辑]
我在下面的回答中错了。我不会删除它(但),因为我对此有7个支持:)。但是我正在编辑它,以便你们所有人都有机会撤回您的投票(甚至投票,因为我应得的)。
原始答案
哈!..我找到了。
简短答案:您不能!
长答案:如果有人知道数组和对象之间的区别,那么您应该可以这样做。
理论上这应该可行
<field1>
....
</field1>
<field2>
....
<depends>
<field1>
<value>1|2</value>
<separator>|</separator>
</field1>
</depends>
</field2>
但是在处理依赖关系的代码中,Mage_Adminhtml_Block_System_Config_Form::initFields
第366行附近有此代码
if (isset($dependent['separator'])) {
$dependentValue = explode((string)$dependent['separator'], $dependentValue);
}
$dependent
始终是一个对象,因此$dependent['separator']
永远不会设置。
如果我将上面的代码更改为
if (isset($dependent->separator)) {
$dependentValue = explode((string)$dependent->separator, $dependentValue);
}
一切顺利。
我想我不能仅仅为了扩展而更改内核,所以我必须创建2个字段而不是1个字段,field1
或者为每个值创建一个字段,或者创建一个处理该字段并将其添加到配置页面的自定义js。