0

I've added the following observer which adds a custom text field to the CMS Page Information:

$fieldset = $form->addFieldset('lcms_author_fieldset', array('legend'=>Mage::helper('cms')->__('Custom'),'class'=>'fieldset-wide'));

$fieldset->addField('author', 'text', array(
  'name'      => 'author',
  'label'     => Mage::helper('cms')->__('Author'),
  'title'     => Mage::helper('cms')->__('Author'),
  'disabled'  => false,

  'value'     => $model->getauthor()
));

How could I change this to be a dropdown? Ideally the select options would be generated from an attribute but I don't mind hard-coding them if it makes it 10x easier.

| improve this question | | | | |
0

I've figured this out now, you need to change text to select and add values as an array. I've also added an extra line so that if a value is found in the database it is selected by default:

$fieldset = $form->addFieldset('lcms_author_fieldset', array('legend'=>Mage::helper('cms')->__('Custom'),'class'=>'fieldset-wide'));

$fieldset->addField('author', 'select', array(
  'name'      => 'author',
  'label'     => Mage::helper('cms')->__('Author'),
  'title'     => Mage::helper('cms')->__('Author'),
  'disabled'  => false,
  'values'    => array('Value 1', 'Value 2', 'Value 3')
));

if ($model->getauthor()) {
  $model->setData('author', $model->getauthor());
}
| improve this answer | | | | |

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.