1

hi i want to add a class to the select field in the multishipper addresses.phtml screen. the function is

 echo $this->getAddressesHtmlSelect($_item, $_index)

that is calling the select with addresses droplist. this function is found in Addresses.php

  public function getAddressesHtmlSelect($item, $index)
    {
        $select = $this->getLayout()->createBlock('core/html_select')
            ->setName('ship['.$index.']['.$item->getQuoteItemId().'][address]')
            ->setId('ship_'.$index.'_'.$item->getQuoteItemId().'_address')
            ->setValue($item->getCustomerAddressId())
            ->setOptions($this->getAddressOptions());

        return $select->getHtml();
    }

i thought that the options would work because the select field is generated with the class attribute empty.

i tried the following syntax $this->getAddressesHtmlSelect($_item, $_index, 'form-control') without success..

1 Answer 1

1

You can add a class through javsscript by element id in your template (phtml) file. This is the only method to add class in your select box, without changing the core files and rewrite the block.

<script>
     $('id-of-your-select-box').addClassName('yourclass');
</script>
3
  • thanks, i was suspecting this. i just cant believe how badly designed that is. we should not have to resort to javascript to create markup.
    – liz
    Aug 12, 2014 at 17:26
  • Then you have to rewrite that block Aug 12, 2014 at 17:34
  • yeah, i get it. i just think its badly designed. you shouldnt have to spend hours rewriting a block in order to add a class. and you shouldnt have to do it with js as your alternative. thanks for the info
    – liz
    Aug 12, 2014 at 23:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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