Use select viewHelper in test form
authorstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Tue, 22 Apr 2014 21:20:01 +0000 (21:20 +0000)
committerstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Tue, 22 Apr 2014 21:20:01 +0000 (21:20 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/static_info_tables/trunk@84959 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
Classes/Controller/ManagerController.php
Classes/ViewHelpers/Form/SelectViewHelper.php
Resources/Private/Templates/Manager/TestForm.html

index f8cd100..5326db3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
        * Resolves #56327: Add select viewHelper with values from tables (Thanks to Carsten Biebricher)
        * Resolves #58100: Incorrect annotation for tableName on AbstractEntity
        * Resolves #58107: Add countryZones to country domain model
+       * Use select viewHelper in test form
 
 2014-03-26  Stanislas Rolland  <typo3@sjbr.ca>
 
index 3647f9b..70b24db 100644 (file)
@@ -224,27 +224,18 @@ class ManagerController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControll
         * @return string An HTML form
         */
        public function testFormAction(Country $country = NULL, CountryZone $countryZone = NULL, Language $language = NULL) {
-               if (is_object($country) && (is_object($countryZone) || !$this->countryZoneRepository->findByCountry($country)->count())) {
+               if (is_object($country) && (is_object($countryZone) || !$country->getCountryZones()->count())) {
                        $this->forward('testFormResult', 'Manager', $this->extensionName, array('country' => $country, 'countryZone' => $countryZone, 'language' => $language));        
                }
-               $countries = $this->countryRepository->findAllOrderedBy('nameLocalized');
                if (is_object($country)) {
-                       $countryZones = $this->countryZoneRepository->findByCountry($country);
-                       $selectedCountry = $country->getUid();
-                       $this->view->assign('selectedCountry', $country->getUid());
-               } else {
-                       $countryZones = array();
-               }
-               $languages = $this->languageRepository->findAllNonConstructedNonSacred()->toArray();
-               if (is_object($language)) {
-                       $this->view->assign('selectedLanguage', $language->getUid());
+                       $this->view->assign('selectedCountry', $country);
                }
-               $this->view->assign('countries', $countries);
-               $this->view->assign('countryZones', $countryZones);
                if (is_object($countryZone)) {
-                       $this->view->assign('selectedCountryZone', $countryZone->getUid());
+                       $this->view->assign('selectedCountryZone', $countryZone);
+               }
+               if (is_object($language)) {
+                       $this->view->assign('selectedLanguage', $language);
                }
-               $this->view->assign('languages', $languages);
        }
 
        /**
index 1bcfee9..f59f23e 100644 (file)
@@ -201,6 +201,9 @@ class SelectViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\SelectViewHelpe
                /** @var array $items */
                if ($this->hasArgument('staticInfoTableSubselect')) {
                        $items = $this->emitGetItemsWithSubselect($repository);
+               } else if ($repository === 'languageRepository') {
+                       $items = $this->{$repository}->findAllNonConstructedNonSacred()
+                               ->toArray();
                } else {
                        $items = $this->{$repository}->findAll()
                                ->toArray();
@@ -249,10 +252,12 @@ class SelectViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\SelectViewHelpe
                        ));
 
                        $this->arguments = $list['arguments'];
-                       $items = $list['items'];
+                       if ($list['items']) {
+                               $items = $list['items']->toArray();
+                       }
                }
 
-               return $items->toArray();
+               return $items;
        }
 
        /**
index 63df627..60ab83e 100644 (file)
@@ -1,3 +1,4 @@
+{namespace static=SJBR\StaticInfoTables\ViewHelpers}
 <f:layout name="Default" />
 
 <f:section name="Content">
                                <label for="sjbr-static-info-tables-manager-country">{f:translate(key: 'selectCountry')}:</label>
                        </dt>
                        <dd>
-                               <f:form.select id="sjbr-static-info-tables-manager-country" name="country" options="{countries}" value="{selectedCountry}" optionLabelField="nameLocalized" additionalAttributes="{onchange:'javascript:this.form.submit();'}" />
+                               <static:form.select id="sjbr-static-info-tables-manager-country" name="country" staticInfoTable="country" options="{}" value="{selectedCountry}" additionalAttributes="{onchange:'javascript:this.form.submit();'}"/>
                        </dd>
-                               <f:if condition="{countryZones}">
+                       <f:if condition="{selectedCountry}">
+                               <f:if condition="{selectedCountry.countryZones}">
                                        <dt>
                                                <label for="sjbr-static-info-tables-manager-country-zone">{f:translate(key: 'selectCountryZone')}:</label>
                                        </dt>
                                        <dd>
-                                               <f:form.select id="sjbr-static-info-tables-manager-country-zone" name="countryZone" options="{countryZones}" value="{selectedCountryZone}" optionLabelField="nameLocalized" />
+                                               <static:form.select id="sjbr-static-info-tables-manager-country-zone" name="countryZone" staticInfoTable="countryZone" staticInfoTableSubselect="{country: '{selectedCountry.uid}'}" options="{}" value="{selectedCountryZone}" />
                                        </dd>
                                </f:if>
+                       </f:if>
                        <dt>
                                <label for="sjbr-static-info-tables-manager-language">{f:translate(key: 'selectLanguage')}:</label>
                        </dt>
                        <dd>
-                               <f:form.select id="sjbr-static-info-tables-manager-language" name="language" options="{languages}" value="{selectedLanguage}" optionLabelField="nameLocalized" sortByOptionLabel="1"/>
+                               <static:form.select id="sjbr-static-info-tables-manager-language" name="language" staticInfoTable="language" options="{}" value="{selectedLanguage}" />
                        </dd>
                        <dt>
                        </dt>