[FLOW3-general] Validate if an object is unique

Manfred Rutschmann - VOLUMEN Werbe-/Internetagentur rutschmann at agentur-volumen.de
Thu Feb 28 14:25:35 CET 2013


Hi Cornel,

that`s not true:

	/**
	 * createAction
	 * @param \Kunden\Domain\Model\Country $country
	 * @return void
	 * 
	 */
	public function createAction(\Kunden\Domain\Model\Country $country){
		$checkIdentity = $this->countryRepository->findByName($country->getName())->count();
		if($checkIdentity > 0){
			$this->forward("new", NULL, NULL, array("country"=>$country));
		} else {
			$this->countryRepository->add($country);
			$this->redirect("list");
		}
	}	

You can forward to the new action and use the given object as a argument, then all fields are filled with the old values before submitted. By the way, this from Bastian is interesting:

@Flow\Validate(argumentName="$user", type="UniqueEntity", options={"identityProperties"={"emailAddress"}})

i think i would give this a try too.

Regards Manfred



Am 28.02.2013 um 13:19 schrieb Widmer Cornel <cornel at kollerinternet.ch>:

> Hi Manfred
> 
> I thinked over this solution but there is a problem. How did you handle the inputs that a user has made.
> In case you have a big form it isnt really handy that every input field get lost.
> 
> Greetings, Cornel
> 
> 
> Quote: Manfred Rutschmann - VOLUMEN Werbe-/Internetag wrote on Thu, 28 February 2013 10:58
> ----------------------------------------------------
>> Hi Cornel,
>> i have the same problem. For this way you can`t catch the given Excpetion. For this case i have to use a little check in the controller:
>> $checkIdentity = $this->countryRepository->findByName($country->getName())->count();
>> Dirty but effective ;-)
>> Regards Manfred
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general



More information about the FLOW3-general mailing list