[TYPO3-english] Get hidden object on controller
lolli at schwarzbu.ch
Thu Apr 25 21:08:28 CEST 2013
Hey Sergio :)
On 04/25/2013 11:34 AM, Sergio Catalá wrote:
> I have this line in my controller:
> $author = $book->getAuthor();
> where field "author" is an Object that has other fields.
> If I set this object to hidden in the backend, this line fails because
> the object is null.
> I've read some stuff about the "setRespectEnableFields" function and set
> it to FALSE, but it seems this applies to repositories.
> Can you give me a clue to get the line working despite the object is
> hidden. I want to keep allowing the backend user to hide these objects.
This is an extbase related question, your mail is probably better placed
in the MVC or the dev list.
I understood your question this way:
You have a model, with a property pointing to another model (no object
storage). If the sub object is "hidden", it is not fetched from
persistence, but you still want to have it instantiated and added to
your parent model.
This can AFAIK not be solved using repository settings for the child
object, as the dataMapper does own magic and doesn't call repositories
for resolving sub objects.
A 'hack' to solve this: Go to your parent's getBook(). If the property
is null, query the parent table with for the child id, then call the
childRepository with findHiddenByUid() or something and this repository
method then sets the needed querySettings and returns the object ... If
you have your object then, set it to the property and return it. If the
answer is still null, you might want to cache this information in the
model, so the query is not fired again if you call getBook() again.
Anyone with a better solution?
More information about the TYPO3-english