2

I try it but not working. everyone can help me plz! enter image description here

Muhammad Anas
1,4673 gold badges13 silver badges33 bronze badges
asked May 24, 2019 at 2:14

3 Answers 3

-1

If you are using magento2.3.1 need to change your filed component code in xml file like below

 <field name="sort_order" formElement="input">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
 <item name="source" xsi:type="string">page</item>
 </item>
 </argument>
 <settings>
 <validation>
 <rule name="required-entry" xsi:type="boolean">true</rule>
 </validation>
 <dataType>text</dataType>
 <label translate="true">Sort Order</label>
 <dataScope>sort_order</dataScope>
 <imports>
 <link name="disabled">${ $.provider}:data.do_we_hide_it</link>
 </imports>
 </settings>
 </field>
answered May 24, 2019 at 4:29
5
  • your dataProvider code will remain same... just change your filed code like above Commented May 24, 2019 at 4:30
  • Do you know hidden fieldset ? Commented May 24, 2019 at 6:10
  • @NewBie means? what is your requirement? Commented May 24, 2019 at 6:12
  • 1
    I want hide tab in form ui components. Commented May 24, 2019 at 6:14
  • @NewBie Please add new question ... If not me other can help you!! Commented May 24, 2019 at 6:18
1

You can override getMeta() function in your DataProvider class

public function getMeta()
 {
 $meta = parent::getMeta();
 $id = $this->request->getParam('entity_id');
 if(isset($id)){
 $meta['fieldset_name']['arguments']['data']['config']['visible'] = 1;
 }
 else{
 $meta['fieldset_name']['arguments']['data']['config']['visible'] = 0;
 }
 return $meta;
 }

This worked for me.

answered Sep 7, 2020 at 5:09
0

You need to add the class into the fieldset tab as below.

<fieldset name="testingproduct" class="Vendor\Module\Ui\Component\Custom\Form\CustomFieldset">
 <argument name="data" xsi:type="array">
 <item name="config" xsi:type="array">
...

You need to add the fieldset condition in the specified class.

<?php
namespace Vendor\Module\Ui\Component\Custom\Form;
use Magento\Framework\View\Element\UiComponent\ContextInterface;
use Magento\Ui\Component\Form\Fieldset;
class CustomFieldset extends Fieldset
{
 public function __construct(
 ContextInterface $context,
 array $components = [],
 array $data = []
 ) {
 $this->context = $context;
 parent::__construct($context, $components, $data);
 }
 //This method is responsible for show and hide the fieldset
 public function prepare()
 {
 $visiable = false; // do some work to get boolean value;
 $config = $this->getData('config');
 $config['visible'] = $visiable;
 $this->setData('config', $config);
 parent::prepare();
 }
}

Thanks :)

answered Aug 24, 2023 at 9:36

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.