On 11/13/2014 07:22 PM, Stefan Padberg wrote: > Hi, > > hier gibt es ein Problem mit den Fluid-Checkboxen. > > Das Objekt kann mehrere Kategorien (von 'sys_categories') haben. Im FE > ist ein Edit-Formular, mit dem die Kategorien gesetzt werden können. > Das funktioniert. > > <f:for each="{sysCategories}" as="sysCategory"> > <f:form.checkbox property="categories" value="{sysCategory.uid}" /> > </f:for> > > {sysCategories} ist ein eigens erzeugtes Array, mit dem Kategorienbaum > mit seinen Ebenen nachgebildet wird. > > Aber die Checkboxen sind nicht vorbelegt. > > Die Vorbelegung bekomme ich in, wenn ich das Formular mit dem > input-Tag aufbaue und eine verschachtelte f:for-f:if-Konstruktion für > die Abfrage der Objekt-Kategorien mache. Aber damit wird der > selektierte Wert nicht im Objekt abgespeichert. > > Hat jemand so etwas schonmal gemacht und kann hier helfen? > > Beste Grüße > Stefan >
Hallo Stefan, mit dem neuen Property-Mapper habe ich es bis jetzt nicht zum Laufen gekriegt. Ich habe gerade vor wenigen Minuten auf der MVC-Liste geposted. Ich zitiere hier einfach mal (wahrscheinlich verstösst das gegen 100 Mailinglists-Regeln, hihi): -------- Forwarded Message -------- Subject: Re: [TYPO3-mvc] T3 6.2: Checkbox Viewhelper and n:m Relation - Wrong field name Date: Fri, 14 Nov 2014 12:20:37 +0100 From: g4-l...@tonarchiv.ch Reply-To: TYPO3 v4 MVC project <typo3-project-typo3v4...@lists.typo3.org> To: typo3-project-typo3v4...@lists.typo3.org Hi Jonas, I couldn't find a neat solution yet... I'm doing it now without "property" argument, but by naming the form fields by myself, like: <f:form.checkbox name="categoryArray[{category.uid}]" value="true" checked="{h:hasCategory(shop:shop, category:category)} /> As you can see I still need an array and also a custom viewhelper for setting the flags properly. BR, Till On 11/13/2014 02:14 PM, Jonas Eberle wrote: > I am at the same point right now (managing sets of attributes that can > be switched on or off in an n:m-property with Fluid forms). > > Did you find an elegant solution? > > Regards, > Jonas > > Am 09.09.2014 um 06:30 schrieb g4-l...@tonarchiv.ch: >> I wonder how checkbox viewhelper should be used for n:m properties of an >> object. >> >> Let's say we have an object Shop with property Category which is n:m >> related, i.e. each shop may have one or more categories. >> >> In T3 i used an array for this type of property, which was mapped and >> added to a object storage in the setter method (and vice versa in >> getter): >> >> /** >> * Set the categoryArray >> * >> * @param array $categoryArray >> * @return void >> */ >> public function setCategoryArray($categoryArray) { >> $categoryRepository = >> t3lib_div::makeInstance('Tx_Myext_Domain_Repository_CategoryRepository'); >> >> $this->categories = new >> Tx_Extbase_Persistence_ObjectStorage; >> foreach($categoryArray as $category_id){ >> $category = $categoryRepository->findByUid($category_id); >> $this->addCategory($category); >> } >> } >> >> This was ugly, but it was the only way to have the checkboxes checked >> correctly by the viewhelper: >> >> <f:for each="{categories}" as="category"> >> <div class="innerRow"> >> <label> >> <f:form.checkbox property="categoryArray" >> value="{category.uid}"/> >> {category.name} >> </label> >> </div> >> </f:for> >> >> I.e. the appropriate checkboxes are checked when the form is loaded. >> >> With the new property mapper i get a problem: The checkbox viewhelper >> renders the Category property as a string and not as an array: >> ... >> <input type="checkbox" value="1" >> name="tx_myext_fe_shopedit[shop][categories]">Cat >> 1 >> ... >> <input type="checkbox" value="2" >> name="tx_myext_fe_shopedit[shop][categories]">Cat >> 2 >> >> I get the error: #1297759968: Exception while property mapping at >> property path "categoryArray":No converter found which can be used to >> convert from "string" to "array" >> >> So what is the right way to do this? >> Why does the viewhelper not render the property as an array? >> i.e. >> <input type="checkbox" value="1" >> name="tx_myext_fe_shopedit[shop][categories][]">Cat >> 1 (like with T4.6) >> >> Cheers, >> Till >> >> _______________________________________________ >> TYPO3-project-typo3v4mvc mailing list >> typo3-project-typo3v4...@lists.typo3.org >> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc > > _______________________________________________ TYPO3-project-typo3v4mvc mailing list typo3-project-typo3v4...@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc _______________________________________________ TYPO3-german mailing list TYPO3-german@lists.typo3.org http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-german