[FLOW3-general] Creation of Objects not allowed
Manfred Rutschmann - VOLUMEN Werbe-/Internetagentur
rutschmann at agentur-volumen.de
Wed Mar 27 07:16:01 CET 2013
Ok, i work now with an array instead of an own object for this form. That works perfectly.
Kind regards Manfred
Am 26.03.2013 um 11:11 schrieb Manfred Rutschmann - VOLUMEN Werbe-/Internetagentur <rutschmann at agentur-volumen.de>:
>
> Hey List,
>
> i need a ValueObject. I`ve created a model for this:
>
> <?php
> namespace Kunden\Domain\Model;
>
> /* *
> * This script belongs to the FLOW3 package "Kunden". *
> * *
> * */
>
> use TYPO3\FLOW3\Annotations as FLOW3;
>
>
> /**
> * A Import Object
> *
> * @FLOW3\ValueObject
> */
>
> class Import {
>
> /**
> * The table
> * @FLOW3\Validate(type="NotEmpty")
> * @var string
> */
> protected $table;
> /**
> * Constructs this Aktion
> *
> */
> public function __construct() {
>
> }
>
>
> /**
> * Get the Aktion's table
> *
> * @return string The import's table
> */
> public function getTable() {
> return $this->table;
> }
>
>
> }
> ?>
>
> My template looks like this:
>
>
> <f:layout name="Access" />
>
> <f:section name="Content">
> <div class="tablelessContent ui-corner-all">
> <h3>Importassistent</h3>
> <h4>Schritt 1: Ziel wählen</h4>
> <p>Bitte wählen Sie ein Ziel für den Datenimport. Es werden alle Tabellen aufgelistet die für einen Import aktiviert sind:</p>
>
> <f:form action="upload" absolute="1" controller="Import" method="post" name="import" object="{import}" class="importStep1">
> <select class="visualselect" name="import[table]">
> <option>Bitte wählen</option>
> <f:for each="{tables}" as="table" iteration="i">
> <option value="{i.index}">{table.tableName}</option>
> </f:for>
> </select>
>
> <f:form.submit value="Weiter zu Schritt 2" class="ui-button"/>
> </f:form>
> </div>
>
> </f:section>
>
>
> And the Controller:
>
>
> /**
> * Index action
> * @param \Kunden\Domain\Model\Import $import
> * @return void
> */
> public function indexAction(\Kunden\Domain\Model\Import $import = NULL) {
> $i=0;
> foreach ($this->classesToProcess as $class) {
> $classArray[$i]["className"] = $this->$class->getEntityClassName();
> $classArray[$i]["tableName"] = strtolower(str_replace("\\", "_", $this->$class->getEntityClassName()));
> $classArray[$i]["repositoryName"] = $class;
> $i++;
> }
> if($import === NULL){
> //$import = new \Kunden\Domain\Model\Import;
> }
>
> $this->view
> ->assign("import", $import)
> ->assign("tables", $classArray);
>
> }
>
>
> /**
> * initializeUploadAction
> * @return void
> */
> public function initializeUploadAction() {
> $this->arguments['import']->getPropertyMappingConfiguration()->allowProperties('table');
> //$this->arguments['import']->getPropertyMappingConfiguration()->allowCreationForProperty('table');
> $this->arguments['import']->getPropertyMappingConfiguration()->allowCreationForSubProperty('import.table');
> }
> /**
> * Upload action
> * @param \Kunden\Domain\Model\Import $import
> * @return void
> */
> public function uploadAction(\Kunden\Domain\Model\Import $import) {
> \TYPO3\FLOW3\var_dump($import);
> }
>
>
> Now after sending the form i get this:
>
> #1297759968: Exception while property mapping for target type "Kunden\Domain\Model\Import", at property path "": Creation of objects not allowed. To enable this, you need to set the PropertyMappingConfiguration Value "CONFIGURATION_CREATION_ALLOWED" to TRUE
>
>
> Why? It is not easy to use a simple value object and sending this with a form?
>
> Thanks, Manfred
>
>
>
>
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
More information about the FLOW3-general
mailing list