[TYPO3-mvc] Problem with [Model].subclasses and saving
Stefan Frömken
firma at sfroemken.de
Fri Nov 2 10:50:20 CET 2012
Hello MVC-List,
I have an answer table (tx_kequestionnaire_domain_model_answer) and a
model (Tx_KeQuestionnaire_Domain_Model_Answer) with all the getter and
setter methods for the fields in my answer table.
Till now everything works fine.
Now we have the case, that we have different answer types. A good start
to use the subclasses feature of extbase:
# Answertypes
Tx_KeQuestionnaire_Domain_Model_Answer {
subclasses {
Radiobutton = Tx_KeQuestionnaire_Domain_Model_AnswerType_Radiobutton
Checkbox = Tx_KeQuestionnaire_Domain_Model_AnswerType_Checkbox
}
}
Tx_KeQuestionnaire_Domain_Model_AnswerType_Radiobutton {
mapping {
tableName = tx_kequestionnaire_domain_model_answer
recordType = Tx_KeQuestionnaire_Domain_Model_AnswerType_Radiobutton
}
}
Tx_KeQuestionnaire_Domain_Model_AnswerType_Checkbox {
mapping {
tableName = tx_kequestionnaire_domain_model_answer
recordType = Tx_KeQuestionnaire_Domain_Model_AnswerType_Checkbox
}
}
Till now everything works perfectly. I have different models in my
result set.
Now comes the problem:
When I want to save my result I have a relation from the result model to
my answer model:
/**
* Sets the answer
*
* @param Tx_KeQuestionnaire_Domain_Model_Answer $answer
* @return void
*/
public function setAnswer(Tx_KeQuestionnaire_Domain_Model_Answer $answer) {
$this->answer = $answer;
}
As long as I don't work with subclasses this method works. But now
extbase tolds me:
PHP Catchable Fatal Error: Argument 1 passed to
Tx_KeQuestionnaire_Domain_Model_ResultAnswer::setAnswer() must be an
instance of Tx_KeQuestionnaire_Domain_Model_Answer, instance of
Tx_KeQuestionnaire_Domain_Model_AnswerType_Radiobutton given
So...what kind of type I have to add in my setter method?
Stefan
More information about the TYPO3-project-typo3v4mvc
mailing list