[TYPO3-mvc] attach on non-object error

Johannes C. Schulz - EnzephaloN IT-Solutions info at enzephalon.de
Mon Mar 5 09:46:29 CET 2012


Hello Alexander

I have a form, displaying an object called accreditation. Each accreditation
has child-objects called persons. There persons have child-objects called
passport.
In this form I want to "accept" or "deny" accreditations. If accepted, I set
passports for each person. Before this, the person-objects only have "aid"
set.
In the form I have fields like this:
<f:form.select name="person[{person.aid}][passport]" options="{passports}"
optionLabelField="passportname" multiple="TRUE" size="6"/>
<f:form.select name="person[{person.aid}][exchangeticket]"
options="{0:'nein',1:'ja'}" />
The accreditation-object wents back to the controller to be processed. Here
I try find the accreditation-person by "aid" to fill in the properties. A
person can have one or more passports, or none if a "delete"(no property of
model) is set in form.
Some code-snippets from person-model:
	/**
	* passport
	*
	* @var
Tx_Extbase_Persistence_ObjectStorage<Tx_PsoaAccredit_Domain_Model_Passport>
$passport
	*/
	protected $passport;
	/**
	* The constructor of this Accreditation
	*
	* @return void
	*/
	public function __construct(){
		$this->initStorageObjects();
	}
	/**
	 * Initializes all Tx_Extbase_Persistence_ObjectStorage properties.
	 *
	 * @return void
	 */
	protected function initStorageObjects(){
		$this->passport = new
Tx_Extbase_Persistence_ObjectStorage();
	}
	 /**
	* Adds a Passport
	*
	* @param
Tx_Extbase_Persistence_ObjectStorage<Tx_PsoaAccredit_Domain_Model_Passport>
$passport
	* @return void
	*/
	public function addPassport(Tx_PsoaAccredit_Domain_Model_Passport
$passport){
		$this->passport->attach($passport);
	}

Enough, or do you need more?
Johannes

-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org
[mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von
Alexander Schnitzler
Gesendet: Montag, 5. März 2012 09:29
An: typo3-project-typo3v4mvc at lists.typo3.org
Betreff: Re: [TYPO3-mvc] attach on non-object error

Could you provide a little bit more code and explain in a few more sentences
what you want to do?

Anyway, this does not look like a clean solution at all. Especially the
findByUid-calls in the foreach loop. That's not good practise and will slow
down your application. Better use something like $query->in() or
$query->contains() and just have one db-request.
_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc




More information about the TYPO3-project-typo3v4mvc mailing list