[TYPO3-mvc] dummy value for select and property-problem

Sören Kracker s.kracker at kopfstand-mail.de
Tue Jan 17 16:34:35 CET 2012


This should be possible with a ViewHelper:

Create a file AdvancedSelectViewHelper.php in Classes/ViewHelpers/Form/ 
with this content:

class Tx_Myext_ViewHelpers_Form_AdvancedSelectViewHelper extends 
Tx_Fluid_ViewHelpers_Form_SelectViewHelper {

     /**
      *
      * override initializeArguments
      * @return void
      *
      */
     public function initializeArguments() {
         parent::initializeArguments();
         $this->registerArgument('defaultOption', 'string', 'value to 
prepend', FALSE);
     }

     /**
      *
      * override getOptions
      * @return array an associative array of options, key will be the 
value of the option tag
      *
      */
     protected function getOptions() {
         return array("" => $this->arguments['defaultOption']) + 
parent::getOptions();
     }

}

In the Fluid-Template you define the namespace, e.g.
{namespace mynamespace=Tx_Myext_ViewHelpers}

and for your select field:
<mynamespace:form.advancedSelect
                 value="{selectCategory}"
                 id="categorySelector"
                 name="selectCategory"
                 options="{categories}"
                 optionLabelField="name"
                 defaultOption="choose here" />

Am 17.01.2012 11:42, schrieb Johannes C. Schulz - EnzephaloN IT-Solutions:
> Hello Claus
> Thanks for your answer and link. But I don't need a "preselect" - I'm
> looking for a "dummy" like: options: "please choose, option1, option2,
> option3...". But I see that with the select viewhelper there is no
> possibility. Sad. The variant with an<select><option></option></select>  I
> found in Jochen Rau&  Sebastian Kurfürst book "Zukunftssichere
> TYPO3-Extensions mit Extbase und Fluid". But I think some things in this
> book are now obsolete :-(
> Best regards
> Johannes
>
>
> -----Ursprüngliche Nachricht-----
> Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org
> [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von
> Johannes C. Schulz - EnzephaloN IT-Solutions
> Gesendet: Dienstag, 17. Januar 2012 10:00
> An: 'TYPO3 v4 MVC project'
> Betreff: Re: [TYPO3-mvc] dummy value for select and property-problem
>
> Nobody an idea?
> I spend a lot of time to google the web for a solution, but found nothing
> other as the following code:
> <f:form.select property="magtype" options="{magtypes}"
> optionValueField="uid" optionLabelField="magtypename" class="psoaaccr">
>         <select><option><f:translate key="accr_cr_choose"/></option></select>
> <!-- dummy element -->
> </f:form.select>
> Is there any other solution to make a "choose here" statement within a
> select??
>
> And the inline-translation-problem:
> I often wrote inline-translations, but now it doesn't work:
> <f:form.submit value="{f:translate(key='accr_create')}" />
>
> Why this two doesn't work?
>
>
>
> Thanks
>
> Johannes
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc


More information about the TYPO3-project-typo3v4mvc mailing list