[TYPO3-mvc] FE editing and m:n relations
Raphael Weber
mailinglisten at screensolutions.de
Thu May 24 16:33:26 CEST 2012
Hi,
I'm making my first steps in extension development with extbase/ fluid.
The first plugin i'm working on is a form which allows frontend users to
submit data of their club. This club record contains amongst others a
field to assign fe-users as administrators. For this property I need a
m:n relation between the club data record and the fe_users table.
Creating and editing of these club data records works fine, but when I
submit the data with the FE form, no mm-record is being created and the
field 'administrator' (Club table) gets the value 0.
Did I forget sth important what's especially required for FE-Editing?
MODEL Club:
class Tx_Extkey_Domain_Model_Club extends
Tx_Extbase_DomainObject_AbstractEntity {
/**
* FE user who is permitted to edit the club data
*
* @var
Tx_Extbase_Persistence_ObjectStorage<Tx_Extkey_Domain_Model_Administrator>
*/
protected $administrator;
/**
* FE user who is permitted to edit the club data
*
* @var Tx_Extkey_Domain_Model_Country
*/
protected $country;
/**
* __construct
*
* @param $title
* @param $established
* @param $brandRelated
* @param $termsAccepted
* @param $city
* @param $country
* @param $zip
* @return void
*/
public function __construct($title = NULL, $established = 0,
$brandRelated = true, $termsAccepted = true, $city = NULL, $zip = NULL) {
//Do not remove the next line: It would break the functionality
$this->initStorageObjects();
$this->setTitle($title);
$this->setEstablished($established);
$this->setBrandRelated($brandRelated);
$this->setTermsAccepted($termsAccepted);
$this->setCity($city);
$this->setZip($zip);
}
/**
* Initializes all Tx_Extbase_Persistence_ObjectStorage properties.
*
* @return void
*/
protected function initStorageObjects() {
/**
* Do not modify this method!
* It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead
*/
$this->administrator = new Tx_Extbase_Persistence_ObjectStorage();
}
/**
* Adds a Administrator
*
* @param Tx_Extkey_Domain_Model_Administrator $administrator
* @return void
*/
public function addAdministrator(Tx_Extkey_Domain_Model_Administrator
$administrator) {
$this->administrator->attach($administrator);
}
/**
* Removes a Administrator
*
* @param Tx_Extkey_Domain_Model_Administrator $administratorToRemove
The Administrator to be removed
* @return void
*/
public function removeAdministrator(Tx_Extkey_Domain_Model_Administrator
$administratorToRemove) {
$this->administrator->detach($administratorToRemove);
}
/**
* Returns the administrator
*
* @return
Tx_Extbase_Persistence_ObjectStorage<Tx_Extkey_Domain_Model_Administrator>
$administrator
*/
public function getAdministrator() {
return $this->administrator;
}
/**
* Sets the administrator
*
* @param
Tx_Extbase_Persistence_ObjectStorage<Tx_Extkey_Domain_Model_Administrator>
$administrator
* @return void
*/
public function setAdministrator(Tx_Extbase_Persistence_ObjectStorage
$administrator) {
$this->administrator = $administrator;
}
}
TCA Club:
$TCA['tx_extkey_domain_model_club'] = array(
'columns' => array(
'administrator' => array(
'exclude' => 1,
'label' =>
'LLL:EXT:extkey/Resources/Private/Language/locallang_db.xml:tx_extkey_domain_model_club.administrator',
'config' => array(
'type' => 'select',
'foreign_table' => 'fe_users',
'MM' => 'tx_extkey_club_administrator_mm',
'size' => 10,
'autoSizeMax' => 30,
'maxitems' => 9999,
'multiple' => 0,
'wizards' => array(
),
),
),
),
);
Any hints for a beginner like me ;)
raphael
More information about the TYPO3-project-typo3v4mvc
mailing list