0

So i have a form that saves customer vehicle info in the database with values representing each vehicle.

I also have this array code in my model folder which should be used to display said numbers as names;

class Maker_Modelname_Model_Options_Vehicle_Make
{
public function toOptionArray()
{
     $vmake = array(
        array('value' => 1, 'label' => Mage::helper('vehicle')->__('Alfa Romeo')),
        array('value' => 2, 'label' => Mage::helper('vehicle')->__('AMC')),
        array('value' => 3, 'label' => Mage::helper('vehicle')->__('Aston Martin')),
        array('value' => 4, 'label' => Mage::helper('vehicle')->__('Audi')),
        array('value' => 5, 'label' => Mage::helper('vehicle')->__('Austin')),
        array('value' => 6, 'label' => Mage::helper('vehicle')->__('BMW')),
        array('value' => 7, 'label' => Mage::helper('vehicle')->__('Buick')),
        array('value' => 8, 'label' => Mage::helper('vehicle')->__('Cadillac')),
        array('value' => 9, 'label' => Mage::helper('vehicle')->__('Chevrolet')),
        array('value' => 10, 'label' => Mage::helper('vehicle')->__('Chrysler')),
        array('value' => 11, 'label' => Mage::helper('vehicle')->__('Citroen')),
        array('value' => 12, 'label' => Mage::helper('vehicle')->__('Daihatsu')),
        array('value' => 13, 'label' => Mage::helper('vehicle')->__('Dodge')),
        array('value' => 14, 'label' => Mage::helper('vehicle')->__('Ferrari')),

    );
return $vmake;
}
}

i modified the order view in the admin panel to display the customer vehicle info. I used this code to display it, but its outputs the word "array" which means its not reading the array properly.

<?php $vmake = Mage::getModel('vehicle/options_vehicle_make')
                                    ->toOptionArray(); echo $vmake[$this->htmlEscape($_order->getVehicleMake())] ?>

but i need the model array to convert the values to labels.

Can someone tell me how to do this?

1

You're working with a multi dimensional array, so obviously it will echo array...

You'd need to do something like

echo $vmake[$this->htmlEscape($_order->getVehicleMake())]['label']

Also, why would you html escape the value id?

  • well i did do all of that... just didnt know i needed to add ['label'], which is why it wasnt working. i did remove the html escape in the official codes, the exaple had it because i modified codes that already had it. regardless, thanks. @erfan – Nxlevel Sep 15 '15 at 5:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.