Whenever I render a link
type in admin form field, I often ends up loading the model to render the href
with $helper->getUrl(...)
.
Is there a way I can render the link contents, including href and label, with $form->setValues()
like other fields?
Example:
I don't want this:
$form->addField('link_to_somewhere', 'link', array(
'label' => 'Click me',
'href' => 'http://...',
));
I want something like this:
$form->addField('link_to_somewhere', 'link', array(
'label' => 'Click me',
));
$form->setValues(array(
'link_to_somewhere' => 'http://...'
));
Best Answer
You can natively with the Varien_Data_Form_Element_Link
You can check all the Element type available by browsing the magentoroot/lib/Varien/Data/Form/Element directory
NOTE : the 'value' is overwrite if you call setValue() on the form. Double check that you don't have a line like this below your field declaration