magento 2 : Display Uploaded image in admin form custom moduleImage Preview in admin form magento 2main.CRITICAL: Plugin class doesn't existMagento 2.1 Create a filter in the product grid by new attributeMagento 2 Add new field to Magento_User admin formMagento offline custom Payment method with drop down listMagento 2 Create dynamic array From different Model Collection to use in multi select in gridI have created one field using product form field for my price i want save my field value at product creation time from backend magento2Magento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 Can't view module's front end page output?display uploaded image in custom page in admin gridDisplay custom image in admin edit form magento 2
Possible nonclassical ion from a bicyclic system
What was this black-and-white film set in the Arctic or Antarctic where the monster/alien gets fried in the end?
My player wants to cast multiple charges of magic missile from a wand
How crucial is a waifu game storyline?
Preserving culinary oils
Can a non-EU citizen travel within the Schengen area without identity documents?
find the Integer value after a string from a file
How can I grammatically understand "Wir über uns"?
Is floating in space similar to falling under gravity?
Why would Lupin kill Pettigrew?
How do I subvert the tropes of a train heist?
If Sweden was to magically float away, at what altitude would it be visible from the southern hemisphere?
What are the problems in teaching guitar via Skype?
Beginner's snake game using PyGame
Can't connect to Internet in bash using Mac OS
What are the slash markings on Gatwick's 08R/26L?
How did early x86 BIOS programmers manage to program full blown TUIs given very few bytes of ROM/EPROM?
What is the intuition behind uniform continuity?
Draw a checker pattern with a black X in the center
chmod would set file permission to 000 no matter what permission i try to set
If a massive object like Jupiter flew past the Earth how close would it need to come to pull people off of the surface?
A "distinguishing" family of subsets
Is the world in Game of Thrones spherical or flat?
Select row of data if next row contains zero
magento 2 : Display Uploaded image in admin form custom module
Image Preview in admin form magento 2main.CRITICAL: Plugin class doesn't existMagento 2.1 Create a filter in the product grid by new attributeMagento 2 Add new field to Magento_User admin formMagento offline custom Payment method with drop down listMagento 2 Create dynamic array From different Model Collection to use in multi select in gridI have created one field using product form field for my price i want save my field value at product creation time from backend magento2Magento 2.2.5: Add, Update and Delete existing products Custom OptionsMagento 2.3 Can't view module's front end page output?display uploaded image in custom page in admin gridDisplay custom image in admin edit form magento 2
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I created one form in frontend and from form i submit customer details and also upload one image.
For display all above form data i created admin grid.For show details of grid data while click on grid row i want to show all data don't want to edit or save only show details.But i can't display uploaded image.Please help me to show image in admin form.
My form data as follows :
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Newsletter Template Edit Form Block
*
* @author Magento Core Team <core@magentocommerce.com>
*/
namespace [Vendor][Module_name]BlockAdminhtmlQuotationEdit;
use MagentoStoreModelStoreManagerInterface;
class Form extends MagentoBackendBlockWidgetFormGeneric
/**
* @var SampleGridpart2HelperOption
*/
protected $_statusOption;
protected $_storeManager;
protected $_productloader;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoFrameworkRegistry $registry
* @param MagentoFrameworkDataFormFactory $formFactory
* @param MagentoCmsModelWysiwygConfig $wysiwygConfig
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context, MagentoFrameworkRegistry $registry, MagentoFrameworkDataFormFactory $formFactory, StoreManagerInterface $storemanager, MagentoCatalogModelProductFactory $_productloader,
// SampleGridpart2HelperOption $optionData,
array $data = []
)
//$this->_statusOption = $optionData;
$this->_productloader = $_productloader;
parent::__construct($context, $registry, $formFactory, $data);
/**
* Retrieve template object
*
* @return MagentoNewsletterModelTemplate
*/
public function getLoadProduct($id)
return $this->_productloader->create()->load($id);
public function getModel()
return $this->_coreRegistry->registry('cart2quote_quotation');
protected function _prepareForm()
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$model = $this->getModel();
/** @var MagentoFrameworkDataForm $form */
$form = $this->_formFactory->create(
['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]
);
$imageUrl = $mediaDirectory . 'cart2quote/images/' . $model->getLogoImage();
$flag = false;
if ($model->getLogoImage())
$flag = true;
$fieldset = $form->addFieldset(
'base_fieldset', ['legend' => __('Quotation Information'), 'class' => 'fieldset-wide']
);
if ($model->getId())
$fieldset->addField('id', 'hidden', ['name' => 'id', 'value' => $model->getId()]);
$fieldset->addField(
'product_id', 'label', [
'name' => 'product_id',
'label' => __('Product Name'),
'title' => __('Product Name'),
'value' => $this->getLoadProduct($model->getProductId())->getName()
]
);
$fieldset->addField(
'quote_type', 'label', [
'name' => 'quote_type',
'label' => __('Quotation Type'),
'title' => __('Quotation Type'),
'value' => $model->getQuoteType()
]
);
$fieldset->addField(
'company', 'label', [
'name' => 'company',
'label' => __('Company'),
'title' => __('Company'),
'value' => $model->getCompany()
]
);
$fieldset->addField(
'salutation', 'label', [
'name' => 'salutation',
'label' => __('Salutation'),
'title' => __('Salutation'),
'value' => $model->getSalutation()
]
);
$fieldset->addField(
'first_name', 'label', [
'name' => 'first_name',
'label' => __('First Name'),
'title' => __('First Name'),
'value' => $model->getFirstName()
]
);
$fieldset->addField(
'last_name', 'label', [
'name' => 'last_name',
'label' => __('Last Name'),
'title' => __('Last Name'),
'value' => $model->getLastName()
]
);
$fieldset->addField(
'street', 'label', [
'name' => 'street',
'label' => __('Street'),
'title' => __('Street'),
'value' => $model->getStreet()
]
);
$fieldset->addField(
'number', 'label', [
'name' => 'number',
'label' => __('Number'),
'title' => __('Number'),
'value' => $model->getNumber()
]
);
$fieldset->addField(
'zipcode', 'label', [
'name' => 'zipcode',
'label' => __('Zip Code'),
'title' => __('Zip Code'),
'value' => $model->getZipcode()
]
);
$fieldset->addField(
'city', 'label', [
'name' => 'city',
'label' => __('City'),
'title' => __('City'),
'value' => $model->getCity()
]
);
$fieldset->addField(
'country', 'label', [
'name' => 'country',
'label' => __('Country'),
'title' => __('Country'),
'value' => $model->getCountry()
]
);
$fieldset->addField(
'email', 'label', [
'name' => 'email',
'label' => __('Email'),
'title' => __('Email'),
'value' => $model->getEmail()
]
);
$fieldset->addField(
'phone', 'label', [
'name' => 'phone',
'label' => __('Phone'),
'title' => __('Phone'),
'value' => $model->getPhone()
]
);
$fieldset->addField(
'extra_info', 'label', [
'name' => 'extra_info',
'label' => __('Extra Information'),
'title' => __('Extra Information'),
'value' => $model->getExtraInfo()
]
);
$fieldset->addField(
'message', 'label', [
'name' => 'message',
'label' => __('Message'),
'title' => __('Message'),
'value' => $model->getMessage()
]
);
$fieldset->addField(
'delivery_date', 'label', [
'name' => 'delivery_date',
'label' => __('Delivery Date'),
'title' => __('Delivery Date'),
'value' => $model->getDeliveryDate()
]
);
$fieldset->addField(
'delivery_date_status', 'label', [
'name' => 'delivery_date_status',
'label' => __('Delivery Date Status'),
'title' => __('Delivery Date Status'),
'value' => $model->getDeliveryDateStatus()
]
);
if ($flag === true)
$fieldset->addField(
'logo_image', 'label', [
'name' => 'logo_image',
'label' => __('Logo Image'),
'title' => __('Logo Image'),
'value' => '<img src="' . $imageUrl . '" width="50"/>',
]
);
// $renderer = $this->getLayout()->createBlock('[Vendor][Module Name]BlockAdminhtmlQuotationRendererLogoImage');
//$logo_html->setRenderer($renderer);
$form->setAction($this->getUrl('*/* /save'));
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
magento2 admin grid
add a comment |
I created one form in frontend and from form i submit customer details and also upload one image.
For display all above form data i created admin grid.For show details of grid data while click on grid row i want to show all data don't want to edit or save only show details.But i can't display uploaded image.Please help me to show image in admin form.
My form data as follows :
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Newsletter Template Edit Form Block
*
* @author Magento Core Team <core@magentocommerce.com>
*/
namespace [Vendor][Module_name]BlockAdminhtmlQuotationEdit;
use MagentoStoreModelStoreManagerInterface;
class Form extends MagentoBackendBlockWidgetFormGeneric
/**
* @var SampleGridpart2HelperOption
*/
protected $_statusOption;
protected $_storeManager;
protected $_productloader;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoFrameworkRegistry $registry
* @param MagentoFrameworkDataFormFactory $formFactory
* @param MagentoCmsModelWysiwygConfig $wysiwygConfig
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context, MagentoFrameworkRegistry $registry, MagentoFrameworkDataFormFactory $formFactory, StoreManagerInterface $storemanager, MagentoCatalogModelProductFactory $_productloader,
// SampleGridpart2HelperOption $optionData,
array $data = []
)
//$this->_statusOption = $optionData;
$this->_productloader = $_productloader;
parent::__construct($context, $registry, $formFactory, $data);
/**
* Retrieve template object
*
* @return MagentoNewsletterModelTemplate
*/
public function getLoadProduct($id)
return $this->_productloader->create()->load($id);
public function getModel()
return $this->_coreRegistry->registry('cart2quote_quotation');
protected function _prepareForm()
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$model = $this->getModel();
/** @var MagentoFrameworkDataForm $form */
$form = $this->_formFactory->create(
['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]
);
$imageUrl = $mediaDirectory . 'cart2quote/images/' . $model->getLogoImage();
$flag = false;
if ($model->getLogoImage())
$flag = true;
$fieldset = $form->addFieldset(
'base_fieldset', ['legend' => __('Quotation Information'), 'class' => 'fieldset-wide']
);
if ($model->getId())
$fieldset->addField('id', 'hidden', ['name' => 'id', 'value' => $model->getId()]);
$fieldset->addField(
'product_id', 'label', [
'name' => 'product_id',
'label' => __('Product Name'),
'title' => __('Product Name'),
'value' => $this->getLoadProduct($model->getProductId())->getName()
]
);
$fieldset->addField(
'quote_type', 'label', [
'name' => 'quote_type',
'label' => __('Quotation Type'),
'title' => __('Quotation Type'),
'value' => $model->getQuoteType()
]
);
$fieldset->addField(
'company', 'label', [
'name' => 'company',
'label' => __('Company'),
'title' => __('Company'),
'value' => $model->getCompany()
]
);
$fieldset->addField(
'salutation', 'label', [
'name' => 'salutation',
'label' => __('Salutation'),
'title' => __('Salutation'),
'value' => $model->getSalutation()
]
);
$fieldset->addField(
'first_name', 'label', [
'name' => 'first_name',
'label' => __('First Name'),
'title' => __('First Name'),
'value' => $model->getFirstName()
]
);
$fieldset->addField(
'last_name', 'label', [
'name' => 'last_name',
'label' => __('Last Name'),
'title' => __('Last Name'),
'value' => $model->getLastName()
]
);
$fieldset->addField(
'street', 'label', [
'name' => 'street',
'label' => __('Street'),
'title' => __('Street'),
'value' => $model->getStreet()
]
);
$fieldset->addField(
'number', 'label', [
'name' => 'number',
'label' => __('Number'),
'title' => __('Number'),
'value' => $model->getNumber()
]
);
$fieldset->addField(
'zipcode', 'label', [
'name' => 'zipcode',
'label' => __('Zip Code'),
'title' => __('Zip Code'),
'value' => $model->getZipcode()
]
);
$fieldset->addField(
'city', 'label', [
'name' => 'city',
'label' => __('City'),
'title' => __('City'),
'value' => $model->getCity()
]
);
$fieldset->addField(
'country', 'label', [
'name' => 'country',
'label' => __('Country'),
'title' => __('Country'),
'value' => $model->getCountry()
]
);
$fieldset->addField(
'email', 'label', [
'name' => 'email',
'label' => __('Email'),
'title' => __('Email'),
'value' => $model->getEmail()
]
);
$fieldset->addField(
'phone', 'label', [
'name' => 'phone',
'label' => __('Phone'),
'title' => __('Phone'),
'value' => $model->getPhone()
]
);
$fieldset->addField(
'extra_info', 'label', [
'name' => 'extra_info',
'label' => __('Extra Information'),
'title' => __('Extra Information'),
'value' => $model->getExtraInfo()
]
);
$fieldset->addField(
'message', 'label', [
'name' => 'message',
'label' => __('Message'),
'title' => __('Message'),
'value' => $model->getMessage()
]
);
$fieldset->addField(
'delivery_date', 'label', [
'name' => 'delivery_date',
'label' => __('Delivery Date'),
'title' => __('Delivery Date'),
'value' => $model->getDeliveryDate()
]
);
$fieldset->addField(
'delivery_date_status', 'label', [
'name' => 'delivery_date_status',
'label' => __('Delivery Date Status'),
'title' => __('Delivery Date Status'),
'value' => $model->getDeliveryDateStatus()
]
);
if ($flag === true)
$fieldset->addField(
'logo_image', 'label', [
'name' => 'logo_image',
'label' => __('Logo Image'),
'title' => __('Logo Image'),
'value' => '<img src="' . $imageUrl . '" width="50"/>',
]
);
// $renderer = $this->getLayout()->createBlock('[Vendor][Module Name]BlockAdminhtmlQuotationRendererLogoImage');
//$logo_html->setRenderer($renderer);
$form->setAction($this->getUrl('*/* /save'));
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
magento2 admin grid
Share code what is not working , how else will ppl know what is the issue with the code ?
– Vishwas Bhatnagar
Jan 17 '17 at 6:33
please check Form.php code in my que just updated
– Sneha Panchal
Jan 17 '17 at 6:38
1
You should provide more info this is not sufficient to answer ?
– Ramkishan Suthar
Jan 17 '17 at 6:46
but i just want to display image now it display img tag as a value not image preview so for that above code sufficient
– Sneha Panchal
Jan 17 '17 at 6:48
1
github.com/tzyganu/Magento2SampleModule This will help u
– Ankit Shah
Jan 17 '17 at 7:35
add a comment |
I created one form in frontend and from form i submit customer details and also upload one image.
For display all above form data i created admin grid.For show details of grid data while click on grid row i want to show all data don't want to edit or save only show details.But i can't display uploaded image.Please help me to show image in admin form.
My form data as follows :
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Newsletter Template Edit Form Block
*
* @author Magento Core Team <core@magentocommerce.com>
*/
namespace [Vendor][Module_name]BlockAdminhtmlQuotationEdit;
use MagentoStoreModelStoreManagerInterface;
class Form extends MagentoBackendBlockWidgetFormGeneric
/**
* @var SampleGridpart2HelperOption
*/
protected $_statusOption;
protected $_storeManager;
protected $_productloader;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoFrameworkRegistry $registry
* @param MagentoFrameworkDataFormFactory $formFactory
* @param MagentoCmsModelWysiwygConfig $wysiwygConfig
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context, MagentoFrameworkRegistry $registry, MagentoFrameworkDataFormFactory $formFactory, StoreManagerInterface $storemanager, MagentoCatalogModelProductFactory $_productloader,
// SampleGridpart2HelperOption $optionData,
array $data = []
)
//$this->_statusOption = $optionData;
$this->_productloader = $_productloader;
parent::__construct($context, $registry, $formFactory, $data);
/**
* Retrieve template object
*
* @return MagentoNewsletterModelTemplate
*/
public function getLoadProduct($id)
return $this->_productloader->create()->load($id);
public function getModel()
return $this->_coreRegistry->registry('cart2quote_quotation');
protected function _prepareForm()
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$model = $this->getModel();
/** @var MagentoFrameworkDataForm $form */
$form = $this->_formFactory->create(
['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]
);
$imageUrl = $mediaDirectory . 'cart2quote/images/' . $model->getLogoImage();
$flag = false;
if ($model->getLogoImage())
$flag = true;
$fieldset = $form->addFieldset(
'base_fieldset', ['legend' => __('Quotation Information'), 'class' => 'fieldset-wide']
);
if ($model->getId())
$fieldset->addField('id', 'hidden', ['name' => 'id', 'value' => $model->getId()]);
$fieldset->addField(
'product_id', 'label', [
'name' => 'product_id',
'label' => __('Product Name'),
'title' => __('Product Name'),
'value' => $this->getLoadProduct($model->getProductId())->getName()
]
);
$fieldset->addField(
'quote_type', 'label', [
'name' => 'quote_type',
'label' => __('Quotation Type'),
'title' => __('Quotation Type'),
'value' => $model->getQuoteType()
]
);
$fieldset->addField(
'company', 'label', [
'name' => 'company',
'label' => __('Company'),
'title' => __('Company'),
'value' => $model->getCompany()
]
);
$fieldset->addField(
'salutation', 'label', [
'name' => 'salutation',
'label' => __('Salutation'),
'title' => __('Salutation'),
'value' => $model->getSalutation()
]
);
$fieldset->addField(
'first_name', 'label', [
'name' => 'first_name',
'label' => __('First Name'),
'title' => __('First Name'),
'value' => $model->getFirstName()
]
);
$fieldset->addField(
'last_name', 'label', [
'name' => 'last_name',
'label' => __('Last Name'),
'title' => __('Last Name'),
'value' => $model->getLastName()
]
);
$fieldset->addField(
'street', 'label', [
'name' => 'street',
'label' => __('Street'),
'title' => __('Street'),
'value' => $model->getStreet()
]
);
$fieldset->addField(
'number', 'label', [
'name' => 'number',
'label' => __('Number'),
'title' => __('Number'),
'value' => $model->getNumber()
]
);
$fieldset->addField(
'zipcode', 'label', [
'name' => 'zipcode',
'label' => __('Zip Code'),
'title' => __('Zip Code'),
'value' => $model->getZipcode()
]
);
$fieldset->addField(
'city', 'label', [
'name' => 'city',
'label' => __('City'),
'title' => __('City'),
'value' => $model->getCity()
]
);
$fieldset->addField(
'country', 'label', [
'name' => 'country',
'label' => __('Country'),
'title' => __('Country'),
'value' => $model->getCountry()
]
);
$fieldset->addField(
'email', 'label', [
'name' => 'email',
'label' => __('Email'),
'title' => __('Email'),
'value' => $model->getEmail()
]
);
$fieldset->addField(
'phone', 'label', [
'name' => 'phone',
'label' => __('Phone'),
'title' => __('Phone'),
'value' => $model->getPhone()
]
);
$fieldset->addField(
'extra_info', 'label', [
'name' => 'extra_info',
'label' => __('Extra Information'),
'title' => __('Extra Information'),
'value' => $model->getExtraInfo()
]
);
$fieldset->addField(
'message', 'label', [
'name' => 'message',
'label' => __('Message'),
'title' => __('Message'),
'value' => $model->getMessage()
]
);
$fieldset->addField(
'delivery_date', 'label', [
'name' => 'delivery_date',
'label' => __('Delivery Date'),
'title' => __('Delivery Date'),
'value' => $model->getDeliveryDate()
]
);
$fieldset->addField(
'delivery_date_status', 'label', [
'name' => 'delivery_date_status',
'label' => __('Delivery Date Status'),
'title' => __('Delivery Date Status'),
'value' => $model->getDeliveryDateStatus()
]
);
if ($flag === true)
$fieldset->addField(
'logo_image', 'label', [
'name' => 'logo_image',
'label' => __('Logo Image'),
'title' => __('Logo Image'),
'value' => '<img src="' . $imageUrl . '" width="50"/>',
]
);
// $renderer = $this->getLayout()->createBlock('[Vendor][Module Name]BlockAdminhtmlQuotationRendererLogoImage');
//$logo_html->setRenderer($renderer);
$form->setAction($this->getUrl('*/* /save'));
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
magento2 admin grid
I created one form in frontend and from form i submit customer details and also upload one image.
For display all above form data i created admin grid.For show details of grid data while click on grid row i want to show all data don't want to edit or save only show details.But i can't display uploaded image.Please help me to show image in admin form.
My form data as follows :
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* Newsletter Template Edit Form Block
*
* @author Magento Core Team <core@magentocommerce.com>
*/
namespace [Vendor][Module_name]BlockAdminhtmlQuotationEdit;
use MagentoStoreModelStoreManagerInterface;
class Form extends MagentoBackendBlockWidgetFormGeneric
/**
* @var SampleGridpart2HelperOption
*/
protected $_statusOption;
protected $_storeManager;
protected $_productloader;
/**
* @param MagentoBackendBlockTemplateContext $context
* @param MagentoFrameworkRegistry $registry
* @param MagentoFrameworkDataFormFactory $formFactory
* @param MagentoCmsModelWysiwygConfig $wysiwygConfig
* @param array $data
*/
public function __construct(
MagentoBackendBlockTemplateContext $context, MagentoFrameworkRegistry $registry, MagentoFrameworkDataFormFactory $formFactory, StoreManagerInterface $storemanager, MagentoCatalogModelProductFactory $_productloader,
// SampleGridpart2HelperOption $optionData,
array $data = []
)
//$this->_statusOption = $optionData;
$this->_productloader = $_productloader;
parent::__construct($context, $registry, $formFactory, $data);
/**
* Retrieve template object
*
* @return MagentoNewsletterModelTemplate
*/
public function getLoadProduct($id)
return $this->_productloader->create()->load($id);
public function getModel()
return $this->_coreRegistry->registry('cart2quote_quotation');
protected function _prepareForm()
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$model = $this->getModel();
/** @var MagentoFrameworkDataForm $form */
$form = $this->_formFactory->create(
['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]
);
$imageUrl = $mediaDirectory . 'cart2quote/images/' . $model->getLogoImage();
$flag = false;
if ($model->getLogoImage())
$flag = true;
$fieldset = $form->addFieldset(
'base_fieldset', ['legend' => __('Quotation Information'), 'class' => 'fieldset-wide']
);
if ($model->getId())
$fieldset->addField('id', 'hidden', ['name' => 'id', 'value' => $model->getId()]);
$fieldset->addField(
'product_id', 'label', [
'name' => 'product_id',
'label' => __('Product Name'),
'title' => __('Product Name'),
'value' => $this->getLoadProduct($model->getProductId())->getName()
]
);
$fieldset->addField(
'quote_type', 'label', [
'name' => 'quote_type',
'label' => __('Quotation Type'),
'title' => __('Quotation Type'),
'value' => $model->getQuoteType()
]
);
$fieldset->addField(
'company', 'label', [
'name' => 'company',
'label' => __('Company'),
'title' => __('Company'),
'value' => $model->getCompany()
]
);
$fieldset->addField(
'salutation', 'label', [
'name' => 'salutation',
'label' => __('Salutation'),
'title' => __('Salutation'),
'value' => $model->getSalutation()
]
);
$fieldset->addField(
'first_name', 'label', [
'name' => 'first_name',
'label' => __('First Name'),
'title' => __('First Name'),
'value' => $model->getFirstName()
]
);
$fieldset->addField(
'last_name', 'label', [
'name' => 'last_name',
'label' => __('Last Name'),
'title' => __('Last Name'),
'value' => $model->getLastName()
]
);
$fieldset->addField(
'street', 'label', [
'name' => 'street',
'label' => __('Street'),
'title' => __('Street'),
'value' => $model->getStreet()
]
);
$fieldset->addField(
'number', 'label', [
'name' => 'number',
'label' => __('Number'),
'title' => __('Number'),
'value' => $model->getNumber()
]
);
$fieldset->addField(
'zipcode', 'label', [
'name' => 'zipcode',
'label' => __('Zip Code'),
'title' => __('Zip Code'),
'value' => $model->getZipcode()
]
);
$fieldset->addField(
'city', 'label', [
'name' => 'city',
'label' => __('City'),
'title' => __('City'),
'value' => $model->getCity()
]
);
$fieldset->addField(
'country', 'label', [
'name' => 'country',
'label' => __('Country'),
'title' => __('Country'),
'value' => $model->getCountry()
]
);
$fieldset->addField(
'email', 'label', [
'name' => 'email',
'label' => __('Email'),
'title' => __('Email'),
'value' => $model->getEmail()
]
);
$fieldset->addField(
'phone', 'label', [
'name' => 'phone',
'label' => __('Phone'),
'title' => __('Phone'),
'value' => $model->getPhone()
]
);
$fieldset->addField(
'extra_info', 'label', [
'name' => 'extra_info',
'label' => __('Extra Information'),
'title' => __('Extra Information'),
'value' => $model->getExtraInfo()
]
);
$fieldset->addField(
'message', 'label', [
'name' => 'message',
'label' => __('Message'),
'title' => __('Message'),
'value' => $model->getMessage()
]
);
$fieldset->addField(
'delivery_date', 'label', [
'name' => 'delivery_date',
'label' => __('Delivery Date'),
'title' => __('Delivery Date'),
'value' => $model->getDeliveryDate()
]
);
$fieldset->addField(
'delivery_date_status', 'label', [
'name' => 'delivery_date_status',
'label' => __('Delivery Date Status'),
'title' => __('Delivery Date Status'),
'value' => $model->getDeliveryDateStatus()
]
);
if ($flag === true)
$fieldset->addField(
'logo_image', 'label', [
'name' => 'logo_image',
'label' => __('Logo Image'),
'title' => __('Logo Image'),
'value' => '<img src="' . $imageUrl . '" width="50"/>',
]
);
// $renderer = $this->getLayout()->createBlock('[Vendor][Module Name]BlockAdminhtmlQuotationRendererLogoImage');
//$logo_html->setRenderer($renderer);
$form->setAction($this->getUrl('*/* /save'));
$form->setUseContainer(true);
$this->setForm($form);
return parent::_prepareForm();
magento2 admin grid
magento2 admin grid
edited Jan 17 '17 at 6:37
Sneha Panchal
asked Jan 17 '17 at 6:31
Sneha PanchalSneha Panchal
535426
535426
Share code what is not working , how else will ppl know what is the issue with the code ?
– Vishwas Bhatnagar
Jan 17 '17 at 6:33
please check Form.php code in my que just updated
– Sneha Panchal
Jan 17 '17 at 6:38
1
You should provide more info this is not sufficient to answer ?
– Ramkishan Suthar
Jan 17 '17 at 6:46
but i just want to display image now it display img tag as a value not image preview so for that above code sufficient
– Sneha Panchal
Jan 17 '17 at 6:48
1
github.com/tzyganu/Magento2SampleModule This will help u
– Ankit Shah
Jan 17 '17 at 7:35
add a comment |
Share code what is not working , how else will ppl know what is the issue with the code ?
– Vishwas Bhatnagar
Jan 17 '17 at 6:33
please check Form.php code in my que just updated
– Sneha Panchal
Jan 17 '17 at 6:38
1
You should provide more info this is not sufficient to answer ?
– Ramkishan Suthar
Jan 17 '17 at 6:46
but i just want to display image now it display img tag as a value not image preview so for that above code sufficient
– Sneha Panchal
Jan 17 '17 at 6:48
1
github.com/tzyganu/Magento2SampleModule This will help u
– Ankit Shah
Jan 17 '17 at 7:35
Share code what is not working , how else will ppl know what is the issue with the code ?
– Vishwas Bhatnagar
Jan 17 '17 at 6:33
Share code what is not working , how else will ppl know what is the issue with the code ?
– Vishwas Bhatnagar
Jan 17 '17 at 6:33
please check Form.php code in my que just updated
– Sneha Panchal
Jan 17 '17 at 6:38
please check Form.php code in my que just updated
– Sneha Panchal
Jan 17 '17 at 6:38
1
1
You should provide more info this is not sufficient to answer ?
– Ramkishan Suthar
Jan 17 '17 at 6:46
You should provide more info this is not sufficient to answer ?
– Ramkishan Suthar
Jan 17 '17 at 6:46
but i just want to display image now it display img tag as a value not image preview so for that above code sufficient
– Sneha Panchal
Jan 17 '17 at 6:48
but i just want to display image now it display img tag as a value not image preview so for that above code sufficient
– Sneha Panchal
Jan 17 '17 at 6:48
1
1
github.com/tzyganu/Magento2SampleModule This will help u
– Ankit Shah
Jan 17 '17 at 7:35
github.com/tzyganu/Magento2SampleModule This will help u
– Ankit Shah
Jan 17 '17 at 7:35
add a comment |
2 Answers
2
active
oldest
votes
if ($flag === true)
$fieldset->addField(
'logo_image', 'label', [
'name' => 'logo_image',
'label' => __('Logo Image'),
'title' => __('Logo Image'),
'renderer' => '[Vendor][Module Name]BlockAdminhtmlQuotationRendererLogoImage',
]
);
In LogoImage.php
<?php
namespace [Vendor][Module Name]BlockAdminhtmlQuotationRenderer;
use MagentoBackendBlockWidgetGridColumnRendererAbstractRenderer;
use MagentoFrameworkObject;
use MagentoStoreModelStoreManagerInterface;
class LogoImage extends AbstractRenderer
private $_storeManager;
/**
* @param MagentoBackendBlockContext $context
* @param array $data
*/
public function __construct(MagentoBackendBlockContext $context,
StoreManagerInterface $storemanager, array $data = [])
$this->_storeManager = $storemanager;
parent::__construct($context, $data);
$this->_authorization = $context->getAuthorization();
/**
* Renders grid column
*
* @param Object $row
* @return string
*/
public function render(Object $row)
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$imageUrl = $mediaDirectory.'cart2quote/images/'.$this->_getValue($row);
return '<img src="'.$imageUrl.'" width="50"/>';
add a comment |
Image Form id field_name
Form.php
$fieldset->addType('productimage', 'VendorModuleBlockAdminhtmlPostRendererImage');
$fieldset->addField('field_name', 'productimage', array(
'label' => __('Image')));
Image.php
<?php
namespace VendorModuleBlockAdminhtmlPostRenderer;
use MagentoStoreModelStoreManagerInterface;
class Image extends MagentoFrameworkDataFormElementAbstractElement
private $_storeManager;
/**
* @param MagentoBackendBlockContext $context
* @param array $data
*/
public function __construct(MagentoBackendBlockContext $context,
StoreManagerInterface $storemanager, array $data = [])
$this->_storeManager = $storemanager;
parent::__construct($context, $data);
/**
* get category name
* @param DataObject $row
* @return string
*/
public function getElementHtml()
// here you can write your code.
$html = '';
if ($this->getValue())
$html = $this->getMediaImageHtml($this->getValue());
return $html;
public function getMediaImageHtml($imageName)
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$Image = $this->getValue();
$html = "<img src='".$mediaDirectory.$Image."' height='250px' width='250px'>";
return $html;
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f155035%2fmagento-2-display-uploaded-image-in-admin-form-custom-module%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
if ($flag === true)
$fieldset->addField(
'logo_image', 'label', [
'name' => 'logo_image',
'label' => __('Logo Image'),
'title' => __('Logo Image'),
'renderer' => '[Vendor][Module Name]BlockAdminhtmlQuotationRendererLogoImage',
]
);
In LogoImage.php
<?php
namespace [Vendor][Module Name]BlockAdminhtmlQuotationRenderer;
use MagentoBackendBlockWidgetGridColumnRendererAbstractRenderer;
use MagentoFrameworkObject;
use MagentoStoreModelStoreManagerInterface;
class LogoImage extends AbstractRenderer
private $_storeManager;
/**
* @param MagentoBackendBlockContext $context
* @param array $data
*/
public function __construct(MagentoBackendBlockContext $context,
StoreManagerInterface $storemanager, array $data = [])
$this->_storeManager = $storemanager;
parent::__construct($context, $data);
$this->_authorization = $context->getAuthorization();
/**
* Renders grid column
*
* @param Object $row
* @return string
*/
public function render(Object $row)
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$imageUrl = $mediaDirectory.'cart2quote/images/'.$this->_getValue($row);
return '<img src="'.$imageUrl.'" width="50"/>';
add a comment |
if ($flag === true)
$fieldset->addField(
'logo_image', 'label', [
'name' => 'logo_image',
'label' => __('Logo Image'),
'title' => __('Logo Image'),
'renderer' => '[Vendor][Module Name]BlockAdminhtmlQuotationRendererLogoImage',
]
);
In LogoImage.php
<?php
namespace [Vendor][Module Name]BlockAdminhtmlQuotationRenderer;
use MagentoBackendBlockWidgetGridColumnRendererAbstractRenderer;
use MagentoFrameworkObject;
use MagentoStoreModelStoreManagerInterface;
class LogoImage extends AbstractRenderer
private $_storeManager;
/**
* @param MagentoBackendBlockContext $context
* @param array $data
*/
public function __construct(MagentoBackendBlockContext $context,
StoreManagerInterface $storemanager, array $data = [])
$this->_storeManager = $storemanager;
parent::__construct($context, $data);
$this->_authorization = $context->getAuthorization();
/**
* Renders grid column
*
* @param Object $row
* @return string
*/
public function render(Object $row)
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$imageUrl = $mediaDirectory.'cart2quote/images/'.$this->_getValue($row);
return '<img src="'.$imageUrl.'" width="50"/>';
add a comment |
if ($flag === true)
$fieldset->addField(
'logo_image', 'label', [
'name' => 'logo_image',
'label' => __('Logo Image'),
'title' => __('Logo Image'),
'renderer' => '[Vendor][Module Name]BlockAdminhtmlQuotationRendererLogoImage',
]
);
In LogoImage.php
<?php
namespace [Vendor][Module Name]BlockAdminhtmlQuotationRenderer;
use MagentoBackendBlockWidgetGridColumnRendererAbstractRenderer;
use MagentoFrameworkObject;
use MagentoStoreModelStoreManagerInterface;
class LogoImage extends AbstractRenderer
private $_storeManager;
/**
* @param MagentoBackendBlockContext $context
* @param array $data
*/
public function __construct(MagentoBackendBlockContext $context,
StoreManagerInterface $storemanager, array $data = [])
$this->_storeManager = $storemanager;
parent::__construct($context, $data);
$this->_authorization = $context->getAuthorization();
/**
* Renders grid column
*
* @param Object $row
* @return string
*/
public function render(Object $row)
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$imageUrl = $mediaDirectory.'cart2quote/images/'.$this->_getValue($row);
return '<img src="'.$imageUrl.'" width="50"/>';
if ($flag === true)
$fieldset->addField(
'logo_image', 'label', [
'name' => 'logo_image',
'label' => __('Logo Image'),
'title' => __('Logo Image'),
'renderer' => '[Vendor][Module Name]BlockAdminhtmlQuotationRendererLogoImage',
]
);
In LogoImage.php
<?php
namespace [Vendor][Module Name]BlockAdminhtmlQuotationRenderer;
use MagentoBackendBlockWidgetGridColumnRendererAbstractRenderer;
use MagentoFrameworkObject;
use MagentoStoreModelStoreManagerInterface;
class LogoImage extends AbstractRenderer
private $_storeManager;
/**
* @param MagentoBackendBlockContext $context
* @param array $data
*/
public function __construct(MagentoBackendBlockContext $context,
StoreManagerInterface $storemanager, array $data = [])
$this->_storeManager = $storemanager;
parent::__construct($context, $data);
$this->_authorization = $context->getAuthorization();
/**
* Renders grid column
*
* @param Object $row
* @return string
*/
public function render(Object $row)
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$imageUrl = $mediaDirectory.'cart2quote/images/'.$this->_getValue($row);
return '<img src="'.$imageUrl.'" width="50"/>';
answered Feb 14 '17 at 11:54
Ashish JagnaniAshish Jagnani
4,64022057
4,64022057
add a comment |
add a comment |
Image Form id field_name
Form.php
$fieldset->addType('productimage', 'VendorModuleBlockAdminhtmlPostRendererImage');
$fieldset->addField('field_name', 'productimage', array(
'label' => __('Image')));
Image.php
<?php
namespace VendorModuleBlockAdminhtmlPostRenderer;
use MagentoStoreModelStoreManagerInterface;
class Image extends MagentoFrameworkDataFormElementAbstractElement
private $_storeManager;
/**
* @param MagentoBackendBlockContext $context
* @param array $data
*/
public function __construct(MagentoBackendBlockContext $context,
StoreManagerInterface $storemanager, array $data = [])
$this->_storeManager = $storemanager;
parent::__construct($context, $data);
/**
* get category name
* @param DataObject $row
* @return string
*/
public function getElementHtml()
// here you can write your code.
$html = '';
if ($this->getValue())
$html = $this->getMediaImageHtml($this->getValue());
return $html;
public function getMediaImageHtml($imageName)
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$Image = $this->getValue();
$html = "<img src='".$mediaDirectory.$Image."' height='250px' width='250px'>";
return $html;
add a comment |
Image Form id field_name
Form.php
$fieldset->addType('productimage', 'VendorModuleBlockAdminhtmlPostRendererImage');
$fieldset->addField('field_name', 'productimage', array(
'label' => __('Image')));
Image.php
<?php
namespace VendorModuleBlockAdminhtmlPostRenderer;
use MagentoStoreModelStoreManagerInterface;
class Image extends MagentoFrameworkDataFormElementAbstractElement
private $_storeManager;
/**
* @param MagentoBackendBlockContext $context
* @param array $data
*/
public function __construct(MagentoBackendBlockContext $context,
StoreManagerInterface $storemanager, array $data = [])
$this->_storeManager = $storemanager;
parent::__construct($context, $data);
/**
* get category name
* @param DataObject $row
* @return string
*/
public function getElementHtml()
// here you can write your code.
$html = '';
if ($this->getValue())
$html = $this->getMediaImageHtml($this->getValue());
return $html;
public function getMediaImageHtml($imageName)
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$Image = $this->getValue();
$html = "<img src='".$mediaDirectory.$Image."' height='250px' width='250px'>";
return $html;
add a comment |
Image Form id field_name
Form.php
$fieldset->addType('productimage', 'VendorModuleBlockAdminhtmlPostRendererImage');
$fieldset->addField('field_name', 'productimage', array(
'label' => __('Image')));
Image.php
<?php
namespace VendorModuleBlockAdminhtmlPostRenderer;
use MagentoStoreModelStoreManagerInterface;
class Image extends MagentoFrameworkDataFormElementAbstractElement
private $_storeManager;
/**
* @param MagentoBackendBlockContext $context
* @param array $data
*/
public function __construct(MagentoBackendBlockContext $context,
StoreManagerInterface $storemanager, array $data = [])
$this->_storeManager = $storemanager;
parent::__construct($context, $data);
/**
* get category name
* @param DataObject $row
* @return string
*/
public function getElementHtml()
// here you can write your code.
$html = '';
if ($this->getValue())
$html = $this->getMediaImageHtml($this->getValue());
return $html;
public function getMediaImageHtml($imageName)
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$Image = $this->getValue();
$html = "<img src='".$mediaDirectory.$Image."' height='250px' width='250px'>";
return $html;
Image Form id field_name
Form.php
$fieldset->addType('productimage', 'VendorModuleBlockAdminhtmlPostRendererImage');
$fieldset->addField('field_name', 'productimage', array(
'label' => __('Image')));
Image.php
<?php
namespace VendorModuleBlockAdminhtmlPostRenderer;
use MagentoStoreModelStoreManagerInterface;
class Image extends MagentoFrameworkDataFormElementAbstractElement
private $_storeManager;
/**
* @param MagentoBackendBlockContext $context
* @param array $data
*/
public function __construct(MagentoBackendBlockContext $context,
StoreManagerInterface $storemanager, array $data = [])
$this->_storeManager = $storemanager;
parent::__construct($context, $data);
/**
* get category name
* @param DataObject $row
* @return string
*/
public function getElementHtml()
// here you can write your code.
$html = '';
if ($this->getValue())
$html = $this->getMediaImageHtml($this->getValue());
return $html;
public function getMediaImageHtml($imageName)
$mediaDirectory = $this->_storeManager->getStore()->getBaseUrl(
MagentoFrameworkUrlInterface::URL_TYPE_MEDIA
);
$Image = $this->getValue();
$html = "<img src='".$mediaDirectory.$Image."' height='250px' width='250px'>";
return $html;
answered May 23 at 8:50
ARUNPRABAKARAN MARUNPRABAKARAN M
758215
758215
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f155035%2fmagento-2-display-uploaded-image-in-admin-form-custom-module%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Share code what is not working , how else will ppl know what is the issue with the code ?
– Vishwas Bhatnagar
Jan 17 '17 at 6:33
please check Form.php code in my que just updated
– Sneha Panchal
Jan 17 '17 at 6:38
1
You should provide more info this is not sufficient to answer ?
– Ramkishan Suthar
Jan 17 '17 at 6:46
but i just want to display image now it display img tag as a value not image preview so for that above code sufficient
– Sneha Panchal
Jan 17 '17 at 6:48
1
github.com/tzyganu/Magento2SampleModule This will help u
– Ankit Shah
Jan 17 '17 at 7:35