I am using same form for add and edit functionality. i want to 1 field in add action and 2 field in edit action like: in new action i just want to enter fistname but in edit action i want to edit firstname and lastname both. So is it possible using same form in ui-component?
-
Check this, it may help to you magento.stackexchange.com/questions/173081/… – Chirag Patel Jun 12 '18 at 5:21
-
Have you got solution? – Chirag Patel Jun 12 '18 at 5:56
-
Any time, you are welcome – Chirag Patel Jun 12 '18 at 6:26
-
@ChiragPatel or #RutveeSojitra anyone available? – Emipro Technologies Pvt. Ltd. May 8 '19 at 5:15
-
1@EmiproTechnologiesPvt.Ltd. still not resolved the issue? Ask new question there is a more chance to get more help from other users. – Chirag Patel May 8 '19 at 5:44
First set:
<item name="disabled" xsi:type="string">${ $.provider }:data.do_we_hide_it</item>
Suppose Namespace\Modulename\Model\Notification\DataProvider
is your data provider for UI:
<dataSource name="notification_edit_data_source">
<argument name="dataProvider" xsi:type="configurableObject">
<argument name="class" xsi:type="string">Namespace\Modulename\Model\Notification\DataProvider</argument>
<argument name="name" xsi:type="string">notification_edit_data_source</argument>
Then in its getData
function add the following lines:
public function getData(){
.....
.....
if(condition1)
$this->loadedData[$entity_id]['do_we_hide_it'] = true;
else
$this->loadedData[$entity_id]['do_we_hide_it'] = false;
See the core files
vendor/magento/module-catalog/view/adminhtml/ui_component/category_form.xmlline 377 and
vendor/magento/module-catalog/Model/Category/DataProvider.php
line 303 for an example.
-
Hi @ChiragPatel. I do this. But, It's not working. – Emipro Technologies Pvt. Ltd. May 7 '19 at 11:27
-
-
I have not tried with store specific. but I think the same method is given above and change only
public function getData()
function – Chirag Patel May 7 '19 at 11:34 -
get current store & inside condition check store it might be work. Try and let me know if you face any error. – Chirag Patel May 7 '19 at 11:35
-
If else condition proper working. But, It's always disabled. – Emipro Technologies Pvt. Ltd. May 7 '19 at 11:42