[Flow] Ignore validation errors for related object
Stephen Bungert
stephenbungert at yahoo.de
Tue May 21 10:40:04 CEST 2013
Hello Steffen,
Here is the property definition for my books image property:
---
/**
* The book's image.
*
* @var \Bungert\Library\Domain\Model\Image
* @ORM\OneToOne(cascade={"all"}, orphanRemoval=true)
* @ORM\Column(nullable=TRUE)
*/
protected $image = NULL;
---
And these are my image getters/setters:
---
/**
* Sets image.
*
* @param \Bungert\Library\Domain\Model\Image $image The image for this
book.
* @return void
*/
public function setImage(\Bungert\Library\Domain\Model\Image $image = NULL)
{
$this->image = $image;
}
/**
* Gets image.
*
* @return \Bungert\Library\Domain\Model\Image The book's image.
*/
public function getImage() {
return $this->image;
}
/**
* Removes image.
*
* @return void
*/
public function removeImage() {
$this->image = NULL;
}
---
I can create images when I make a book, I can delete images, my probem is
that I can't create a book unless I make an image. I want the image to be
optional
I'm not sure that it matters, but I also have an initialise update action:
---
public function initializeUpdateAction() {
$propertyMappingConfiguration =
$this->arguments['book']->getPropertyMappingConfiguration();
$propertyMappingConfiguration->allowProperties('genres', 'image');
$propertyMappingConfiguration->setTypeConverterOption(
'TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter',
\TYPO3\Flow\Property\TypeConverter\PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED,
TRUE
);
}
---
That was necessary so that while creating books I could assign/unasign genre
records (mayntomany relationship) to the books, but I also had to add image
as one of the allowed properties. maybe this function isn't correctly done?
"Steffen Wickham" <steffen at gaming-inc.de> schrieb im Newsbeitrag
news:mailman.151.1369125031.570.flow at lists.typo3.org...
> Hello Stephen,
>
> did you add "@ORM\Column(nullable=true)" to your image property? How do
> you annotate the property and implement the setter/getter methods for
> it? Please provide us a little bit more details :)
>
> Best regards,
> Steffen
>
>
> Am 19.05.13 11:30, schrieb Stephen Bungert:
>> I have a form for my main objects - books, they have a onetoone
>> relationship with another object - an image, but an image isn't
>> required. The problem is, that this object has two fields that are
>> required, so my main object's update action reports validation errors.
>>
>> I can create books with images, and images can be deleted too, but I
>> can't save my book without validation errors because of the required
>> fields in the image object.
>>
>> Is there anyway of over-riding these errors in my book's update action?
>>
>> Thanks for any help.
>>
>> Stephen.
>> _______________________________________________
>> Flow mailing list
>> Flow at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow
>
More information about the Flow
mailing list