Magento 2 : Form component

Posted . Visible to the public.

How to set a custom value to the field and make it disable

This requirement can be achieved using DataProvider class of the UI form component

/**
     * @inheritdoc
     */
    public function getMeta()
    {
        $meta = parent::getMeta();
        $meta['general']['children']['version']['arguments']['data']['config']['disabled'] = true;

        /** @var \Vasan\Bidding\Model\ResourceModel\Term\Collection $termCollection */
        $termCollection = $this->collectionFactory->create();
        $termCollection->addOrder('id', 'DESC');
        $term = $termCollection->getFirstItem();

        $verion = 1;
        if ($term->getId() > 0) {
            $verion = $term->getData('version') + 1;
        }
        $meta['general']['children']['version']['arguments']['data']['config']['value'] = $verion;

        return $meta;
    }

vasan
Last edit
vasan
Keywords
Custom, Value
Posted by vasan to vasan's deck (2022-05-01 16:40)