sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

[NEXT_MAJOR] Remove `AbstractAdmin::validate` method and all validation-related methods. #6233

Closed VincentLanglet closed 3 years ago

VincentLanglet commented 4 years ago

As explained in the AdminInterface, the validate method doesn't work well (we have bug issue) and is useless since Symfony have his own form validation.

    /**
     * NEXT_MAJOR: remove this method.
     *
     * @param object $object
     *
     * @deprecated this feature cannot be stable, use a custom validator,
     *             the feature will be removed with Symfony 2.2
     */
    public function validate(ErrorElement $errorElement, $object);

I create this issue because we only added one NEXT_MAJOR comment but there is no real removal-plan, we'll have at least to:

We should also add a deprecation in 3.x.

tambait commented 3 years ago

@VincentLanglet When listed methods are removed, is there anything more to be done (for example is there need to add Symfony's ValidatorInterface somewhere)? I tried to search to see where validate methods are called throughout the code, SetObjectFieldValueAction uses ValidatorInterface and the rest is in the list you provided.

VincentLanglet commented 3 years ago

@VincentLanglet When listed methods are removed, is there anything more to be done (for example is there need to add Symfony's ValidatorInterface somewhere)? I tried to search to see where validate methods are called throughout the code, SetObjectFieldValueAction uses ValidatorInterface and the rest is in the list you provided.

We want to remove all the validation features from the Admin, so there is nothing to add.

I look at SetObjectFieldValueAction and we should keep it.

So it require to add in 3.x

/**
 * NEXT_MAJOR: Remove this methods.
 *
 * @deprecated since sonata-admin/admin-bundle 3.x
 */

In the interface for all the validate-related methods, with an upgrade note and to remove all these methods in master.

tambait commented 3 years ago

And what about defineFormBuilder method in AbstractAdmin it calls attachInlineValidator? I'll remove the line but not sure if any additional action on the method is needed.

VincentLanglet commented 3 years ago

Only the call $this->attachInlineValidator(); should be removed in defineFormBuilder