Question

Problem:

Using the following widgets.xml, I get the following error in system.log:

ERR (3): Warning: array_values() expects parameter 1 to be array, string given in app/code/core/Mage/Widget/Block/Adminhtml/Widget/Options.php on line 209.

widget.xml:

<widgets>
    <elevate_videos_slider type="videos/slider">
        <name>Elevate Video Slider</name>
        <description type="desc">Creates a horizontally scrollable slider of videos.</description>
        <parameters>
            <template>
                <required>1</required>
                <visble>1</visble>
                <value>video/slider.phtml</value>
                <label>Video Slider</label>
                <type>text</type>
            </template>
            <group_type>
                <visible>1</visible>
                <label>Slider Group Type:</label>
                <type>select</type>
                <description>What type of slider is this?</description>
                <source_model>videos/system_config_source_slider_types</source_model>
            </group_type>
            <group_type_trait>
                <required>1</required>
                <visible>1</visible>
                <value></value>
                <label>Trait:</label>
                <type>select</type>
                <description>Select the trait whose videos should be displayed.</description>
                <source_model>videos/system_config_source_slider_type_trait</source_model>
                <depends><group_type>leadership_trait</group_type></depends>
            </group_type_trait>
            <group_type_series>
                <required>1</required>
                <visible>1</visible>
                <value></value>
                <label>Series:</label>
                <type>select</type>
                <description>Select the series whose videos should be displayed.</description>
                <source_model>videos/system_config_source_slider_type_series</source_model>
                <depends><group_type>series</group_type></depends>
            </group_type_series>
            <group_type_custom>
                <required>1</required>  Boolean 
                <visible>1</visible>
                <value></value>
                <label>Video List:</label>
                <type>text</type>
                <description>A comma separated list of product ids that should fill this slider.</description>
                <depends><group_type>custom</group_type></depends>
            </group_type_custom>
            <vertical_orientation>
                <required>1</required>  Boolean 
                <visible>1</visible>
                <value>0</value>
                <label>Vertical Slider?:</label>
                <type>select</type>
                <description>Should the slider be oriented vertically?</description>
                <source_model>adminhtml/system_config_source_yesno</source_model>
            </vertical_orientation>
    </parameters>
</elevate_videos_slider>

The following is the portion of Options.php mentioned in the error:

Options.php:

204:    // dependencies from other fields
205:    $dependenceBlock = $this->getChild('form_after');
206:    $dependenceBlock->addFieldMap($field->getId(), $fieldName);
207:    if ($parameter->getDepends()) {
208:        foreach ($parameter->getDepends() as $from => $row) {
209:            $values = isset($row['values']) ? array_values($row['values']) : (string)$row['value'];
210:            $dependenceBlock->addFieldDependence($fieldName, $from, $values);
211:        }
212:    }

Debugging Attempts:

While debugging, $row within the foreach on line 208 is set to the value to use when checking the dependency field's values. Line 209 seems to suggest it's expecting $row to be an array. The following shows what $from and $row end up containing after line 208:

             $from          $row
               +              +
               |              |
               v              v
<depends><group_type>leadership_trait</group_type></depends>

I'm using Magento EE 1.9.1.1; did the syntax for field dependencies change or am I missing something else?

Was it helpful?

Solution

Your <depends> tag should look like this:

<depends>
    <group_type>
        <value>leadership_trait</value>
    </group_type>
</depends>

You are missing a <value> tag.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top