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?
    – vedu
    May 25, 2018 at 5:17
  • @vedu Please check my answer 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.