I followed as suggested by @bassplayer7
Firstly Added Vendor/Module/Ui/DataProvider/Item/Form/DataProvider.php
File with below code
namespace Vendor\Module\Ui\DataProvider\Item\Form;
use Vendor\Module\Model\ResourceModel\Item\CollectionFactory;
use Magento\Ui\DataProvider\AbstractDataProvider;
use Magento\Ui\DataProvider\Modifier\ModifierInterface;
use Magento\Ui\DataProvider\Modifier\PoolInterface;
class DataProvider extends AbstractDataProvider
{
/**
* @var PoolInterface
*/
private $pool;
/**
* Construct
*
* @param string $name
* @param string $primaryFieldName
* @param string $requestFieldName
* @param CollectionFactory $collection
* @param PoolInterface $pool
* @param array $meta
* @param array $data
*/
public function __construct(
$name,
$primaryFieldName,
$requestFieldName,
CollectionFactory $collection,
PoolInterface $pool,
array $meta = [],
array $data = []
) {
parent::__construct($name, $primaryFieldName, $requestFieldName, $meta, $data);
$this->collection = $collection->create();
$this->pool = $pool;
}
public function getData()
{
/** @var ModifierInterface $modifier */
/** the below foreach code you need to process modifier on your field */
foreach ($this->pool->getModifiersInstances() as $modifier) {
$this->data = $modifier->modifyData($this->data);
}
return $this->data;
}
public function getMeta()
{
$meta = parent::getMeta();
/** @var ModifierInterface $modifier */
foreach ($this->pool->getModifiersInstances() as $modifier) {
$meta = $modifier->modifyMeta($meta);
}
return $meta;
}
}
Then created Vendor/Module/etc/adminhtml/di.xml
with below code
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<virtualType name="Vendor\Module\Ui\DataProvider\Item\Form\Modifier\Pool" type="Magento\Ui\DataProvider\Modifier\Pool">
<arguments>
<argument name="modifiers" xsi:type="array">
<item name="price-modifier" xsi:type="array">
<item name="class" xsi:type="string">Vendor\Module\Ui\DataProvider\Item\Form\Modifier\PriceModifier</item>
<item name="sortOrder" xsi:type="number">20</item>
</item>
</argument>
</arguments>
</virtualType>
<type name="Vendor\Module\Ui\DataProvider\Item\Form\DataProvider">
<arguments>
<argument name="pool" xsi:type="object">Vendor\Module\Ui\DataProvider\Item\Form\Modifier\Pool</argument>
</arguments>
</type>
</config>
And atlast added Modifier Vendor/Module/Ui/DataProvider/Item/Form/Modifier/PriceModifier.php
File with below code
namespace Vendor\Module\Ui\DataProvider\Item\Form\Modifier;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Framework\View\Element\UiComponentFactory;
use Magento\Ui\Component\Listing\Columns\Column;
use Magento\Framework\UrlInterface;
use Magento\Ui\DataProvider\Modifier\ModifierInterface;
class PriceModifier implements ModifierInterface
{
public function __construct(
\Magento\Store\Model\StoreManagerInterface $storeManager
)
{
$this->_storeManager = $storeManager;
}
public function modifyMeta(array $meta)
{
$meta['fieldset'] = [ //here field set name
'children' => [
'price' => [ //here price is field namme
'arguments' => [
'data' => [
'config' => [
'currency_sign' => $this ->_storeManager-> getStore()->getBaseCurrency()->getCurrencySymbol()
]
]
]
]
]
];
return $meta;
}
/**
* {@inheritdoc}
*/
public function modifyData(array $data)
{
return $data;
}
}
By this I was able to show base currency symbol in input field same as in edit product page price field.
xsi:type="string"
then it will print the text defined in item tag not the helper function response – Piyush Jun 25 '18 at 7:19currency_sign
to be provided, dependent on conditions, from the server? In other words, the end result will sometimes be$
, sometimes€
, etc.? – bassplayer7 Jun 26 '18 at 16:54