If you want to customize validation of the UniqueEntity constraint on the server side, then you can create your own controller and route, and change it in the config:
//app/config/config.yml
# ...
fp_js_form_validator:
routing:
check_unique_entity: custom_unique_controller
//app/config/routing.yml
# ...
custom_unique_controller:
pattern: /custom_unique_controller
defaults: { _controller: "AcmeDemoBundle:CustomUnique:index" }
namespace Acme\DemoBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class CustomUniqueController extends Controller
{
public function indexAction(Request $request)
{
$data = $request->request->all();
// ...
}
}
Here you can see what kind of data you will receive in the request:
$data = array (
'message' => 'This value is already used.',
'service' => 'doctrine.orm.validator.unique',
'repositoryMethod' => 'findBy',
'fields' => array ('email'),
'ignoreNull' => '1',
'groups' => array ('Default', 'User'),
'entityName' => 'Acme\DemoBundle\Entity\User',
'data' => array (
'email' => '[email protected]',
)
)
Now, you can create your own logic to check the uniqueness using this input data