Magento – Add Export to csv button in form

This code is add button export to csv in form same as  grid page.

public function getElementHtml()
{

$buttonBlock = $this->getForm()->getParent()->getLayout()->createBlock(‘adminhtml/widget_button’);

$params = array(
‘website’ => $buttonBlock->getRequest()->getParam(‘website’)
);

$data = array(
‘label’     => Mage::helper(‘adminhtml’)->__(‘Download sample CSV’),
‘onclick’   => ‘setLocation(\”.Mage::helper(‘adminhtml’)->getUrl(“*/*/exportCsv”, $params) . ‘conditionName/\’ +\’/tablerates.csv\’ )’,
‘class’     => ”,
);
$html = $buttonBlock->setData($data)->toHtml();
return $html;
}

Enjoy.. 🙂

Advertisements

magento how to add custom image thumbnail in edit form

===================== in app\code\local\Nikunj\Contact\Block\Adminhtml\Contact\Edit\Tab\Form.php

For a specific case where the need to add a specific image, the logical way is to use the input_type “image” like this:

1
2
3
4
5
$fieldset->addField('imagename', 'image', array(
    'label'     => Mage::helper('customerprojects')->__('Thumbnail'),
    'name'      => 'imagename',
));

And the result is the following form:

image showing the icon but with an input field with a browse button and a delete checkbox=======================================================================

if u not store full path in data base then set this code =>

 if($form->getElement(‘imagename‘)->getValue() != ”)
{
$p = $form->getElement(‘imagename‘)->getValue();
$form->getElement(‘filename’)->setValue(‘contact/resized/’ . $p);
}

enjoy 🙂