Controller Code:
/**
* action edit
*
* @param Tx_Someextension_Domain_Model_CompanyProfile $companyProfile
* @return void
*/
public function editAction($companyProfile) {
$accessControlService = $this->objectManager->get('Tx_Someextension_Service_AccessControlService');
if ($accessControlService->hasLoggedInFrontendUser()) {
// ...
$this->view->assign('companyProfile', $companyProfile);
$this->view->assign('sectorOptions', $this->sectorRepository->findAll());
}
}
// ensuring the minimum fields field in current foreign language
public function initializeUpdateAction () {
$ensureOverlayFieldsFilled = array('title', 'address', 'city');
$languages = array(1, 2);
foreach ($languages as $language) {
foreach ($ensureOverlayFieldsFilled as $field) {
if (trim($_REQUEST['tx_someextension_someextension']['overlay'][$language][$field]) == '') {
// ...
}
}
}
}
/**
* action update
*
* @param Tx_Someextension_Domain_Model_CompanyProfile $companyProfile
* @return void
*/
public function updateAction(Tx_Someextension_Domain_Model_CompanyProfile $companyProfile) {
$accessControlService = $this->objectManager->get('Tx_Someextension_Service_AccessControlService');
if ($accessControlService->hasLoggedInFrontendUser()) {
...
$this->companyProfileRepository->update($companyProfile);
...
$this->flashMessageContainer->add(
Tx_Extbase_Utility_Localization::translate('your_data_has_been_saved', $this->extensionName),
NULL,
t3lib_Flashmessage::OK
);
$this->redirect('edit', NULL, NULL, array('companyProfile' => $companyProfile->getUid()));
}
}
Model
class Tx_Someextension_Domain_Model_CompanyProfile extends Tx_Extbase_DomainObject_AbstractEntity {
// ...
/**
* Sectors
*
* @var Tx_Extbase_Persistence_ObjectStorage<Tx_Someextension_Domain_Model_Sector>
* @lazy
*/
protected $sectors;
// ...
/**
* __construct
*
* @return void
*/
public function __construct() {
//Do not remove the next line: It would break the functionality
$this->initStorageObjects();
}
/**
* 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->sectors = new Tx_Extbase_Persistence_ObjectStorage();
// ...
}
// ...
/**
* Adds a Sector
*
* @param Tx_Someextension_Domain_Model_Sector $sector
* @return void
*/
public function addSector(Tx_Someextension_Domain_Model_Sector $sector) {
$this->sectors->attach($sector);
}
/**
* Removes a Sector
*
* @param Tx_Someextension_Domain_Model_Sector $sectorToRemove The Sector to be removed
* @return void
*/
public function removeSector(Tx_Someextension_Domain_Model_Sector $sectorToRemove) {
$this->sectors->detach($sectorToRemove);
}
/**
* Returns the sectors
*
* @return Tx_Extbase_Persistence_ObjectStorage<Tx_Someextension_Domain_Model_Sector> $sectors
*/
public function getSectors() {
return $this->sectors;
}
/**
* Sets the sectors
*
* @param Tx_Extbase_Persistence_ObjectStorage<Tx_Someextension_Domain_Model_Sector> $sectors
* @return void
*/
public function setSectors(Tx_Extbase_Persistence_ObjectStorage $sectors) {
$this->sectors = $sectors;
}
}
Repository
class Tx_Somextension_Domain_Repository_CompanyProfileRepository extends Tx_Extbase_Persistence_Repository {
/**
* defaultOrderings
*
* @var array
*/
protected $defaultOrderings = array(
'profiletype' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING,
'crdate' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING,
);
/**
* initializeObject
*
* @info necessary because of fundamental language overlay handling change in 6.2
* @return void
*/
public function initializeObject() {
$defaultQuerySettings = $this->createQuery()->getQuerySettings();
$defaultQuerySettings->setRespectSysLanguage(FALSE);
if ($GLOBALS['TSFE']->sys_language_uid) {
$defaultQuerySettings->setSysLanguageUid($GLOBALS['TSFE']->sys_language_uid);
}
$this->setDefaultQuerySettings($defaultQuerySettings);
}
// ...
}
Edit Template
<f:flashMessages renderMode="div" />
<f:render partial="FormErrors" arguments="{_all}"/>
<f:form action="update" name="companyProfile" enctype="multipart/form-data" object="{companyProfile}">
...
<f:form.select property="sectors" options="{sectorOptions}" optionValueField="uid" optionLabelField="title" multiple="true" size="8" />
...
<f:render partial="Form/RequiredNotice" />
<f:render partial="Form/Submit" arguments="{buttonText: 'save'}" />
</f:form>
Error stacktrace
Uncaught TYPO3 Exception
#1297759968: Exception while property mapping at property path "sectors":Class Tx_Extbase_Persistence_ObjectStorage<Tx_Someextension_Domain_Model_Sector> does not exist (More information)
TYPO3\CMS\Extbase\Property\Exception thrown in file
/.../www/typo3_src-6.2.10/typo3/sysext/extbase/Classes/Property/PropertyMapper.php in line 106.
16 TYPO3\CMS\Extbase\Property\PropertyMapper::convert(array, "Tx_Someextension_Domain_Model_CompanyProfile", TYPO3\CMS\Extbase\Mvc\Controller\MvcPropertyMappingConfiguration)
/.../www/typo3_src-6.2.10/typo3/sysext/extbase/Classes/Mvc/Controller/Argument.php:
00372: return $this;
00373: }
00374: $this->value = $this->propertyMapper->convert($rawValue, $this->dataType, $this->propertyMappingConfiguration);
00375: $this->validationResults = $this->propertyMapper->getMessages();
00376: if ($this->validator !== NULL) {
15 TYPO3\CMS\Extbase\Mvc\Controller\Argument::setValue(array)
/.../www/typo3_src-6.2.10/typo3/sysext/extbase/Classes/Mvc/Controller/AbstractController.php:
00421: $argumentName = $argument->getName();
00422: if ($this->request->hasArgument($argumentName)) {
00423: $argument->setValue($this->request->getArgument($argumentName));
00424: } elseif ($argument->isRequired()) {
00425: throw new \TYPO3\CMS\Extbase\Mvc\Controller\Exception\RequiredArgumentMissingException('Required argument "' . $argumentName . '" is not set.', 1298012500);
14 TYPO3\CMS\Extbase\Mvc\Controller\AbstractController::mapRequestArgumentsToControllerArguments()
/.../www/typo3_src-6.2.10/typo3/sysext/extbase/Classes/Mvc/Controller/ActionController.php:
00148: call_user_func(array($this, $actionInitializationMethodName));
00149: }
00150: $this->mapRequestArgumentsToControllerArguments();
00151: $this->checkRequestHash();
00152: $this->controllerContext = $this->buildControllerContext();
13 TYPO3\CMS\Extbase\Mvc\Controller\ActionController::processRequest(TYPO3\CMS\Extbase\Mvc\Web\Request, TYPO3\CMS\Extbase\Mvc\Web\Response)
/.../www/typo3_src-6.2.10/typo3/sysext/extbase/Classes/Mvc/Dispatcher.php:
00067: $controller = $this->resolveController($request);
00068: try {
00069: $controller->processRequest($request, $response);
00070: } catch (\TYPO3\CMS\Extbase\Mvc\Exception\StopActionException $ignoredException) {
00071: }
12 TYPO3\CMS\Extbase\Mvc\Dispatcher::dispatch(TYPO3\CMS\Extbase\Mvc\Web\Request, TYPO3\CMS\Extbase\Mvc\Web\Response)
/.../www/typo3_src-6.2.10/typo3/sysext/extbase/Classes/Mvc/Web/FrontendRequestHandler.php:
00054: /** @var $response \TYPO3\CMS\Extbase\Mvc\ResponseInterface */
00055: $response = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Mvc\\Web\\Response');
00056: $this->dispatcher->dispatch($request, $response);
00057: return $response;
00058: }
11 TYPO3\CMS\Extbase\Mvc\Web\FrontendRequestHandler::handleRequest()
/.../www/typo3_src-6.2.10/typo3/sysext/extbase/Classes/Core/Bootstrap.php:
00193: $requestHandler = $requestHandlerResolver->resolveRequestHandler();
00194:
00195: $response = $requestHandler->handleRequest();
00196: // If response is NULL after handling the request we need to stop
00197: // This happens for instance, when a USER object was converted to a USER_INT
10 TYPO3\CMS\Extbase\Core\Bootstrap::handleRequest()
/.../www/typo3_src-6.2.10/typo3/sysext/extbase/Classes/Core/Bootstrap.php:
00182: public function run($content, $configuration) {
00183: $this->initialize($configuration);
00184: return $this->handleRequest();
00185: }
00186:
9 TYPO3\CMS\Extbase\Core\Bootstrap::run("", array)
8 call_user_func_array(array, array)
/is/htdocs/wp1148156_S2ZW3VJZ68/www/typo3_src-6.2.10/typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php:
06620: $content,
06621: $conf
06622: ));
06623: } else {
06624: $GLOBALS['TT']->setTSlogMessage('Method "' . $parts[1] . '" did not exist in class "' . $parts[0] . '"', 3);
...