9
  • I wish to create a form in admin.
  • The purpose of the form is not CRUD.
  • Using blocks for creating forms is marked as deprecated in favor of ui_component forms
  • Is it possible to use a ui component form without a data source?
2
  • Hello @vitoriodachef, did you find any solution? Commented May 25, 2018 at 5:17
  • @vedu Please check my answer Commented May 25, 2018 at 9:17

1 Answer 1

11

From my digging it turns out the data provider is required.

I just implemented a dummy data provider.

class Form extends \Magento\Ui\DataProvider\AbstractDataProvider
{
    /**
     * Get data
     *
     * @return array
     */
    public function getData()
    {
        return [];
    }

    public function addFilter(\Magento\Framework\Api\Filter $filter)
    {
        return;
    }
}

I had to override both methods that work with $collection member to avoid errors.

1
  • Does that works still on 2.4.6 ? Commented Feb 1, 2024 at 7:38

Your Answer

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.