[TYPO3-mvc] Fluid form with DateTIme as user input

Hendrik Nadler nadler at simplethings.de
Fri Aug 23 15:44:00 CEST 2013


Hi,

thanks a lot, but somehow this wont work for me (TYPO3 6.1 by the way).

The form field stays empty, if i dont do the constructor thingy (xyz= new DateTime()), otherwise everytime the default date is displayed and cant be changed, because (in your case) "blub.validUntil" - assigned to the view in the controller by:

public function indexAction(\Foo\Bar\Domain\Model\Blub $blub = null)
    {
        if ($blub === null) {
            $blub = $this->objectManager->get('\Foo\Bar\Domain\Model\Blub');
        }
        $this->view->assign('blub', $blub);

is always at the default value and has nothing(?!) to do with the form object. 

Hendrik

-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von Patrick Schriner
Gesendet: Freitag, 23. August 2013 12:29
An: typo3-project-typo3v4mvc at lists.typo3.org
Betreff: Re: [TYPO3-mvc] Fluid form with DateTIme as user input

<label for="validUntil"><f:translate
key="tx_bla_domain_model_blub.valid_until" /> (Format: TT.MM.JJJJ)</label>
	<f:form.textfield property="validUntil"   
value="{blub.validUntil->f:format.date(format:'d.m.Y')}" class="tcal" />

should  work if changed to accept date time. I can only recommend adding a simple date picker like Tigra Calendar.

You should not need any magic in the model, you don't need to set it explicitly - there is a special part in the property mapper that handles datetime fields.

If that fails you,

http://forum.typo3.org/index.php?t=msg&th=196836&goto=685637&#msg_685637

looks promising.

Patrick

On Fri, 23 Aug 2013 12:11:01 +0200, Hendrik Nadler <nadler at simplethings.de> wrote:

> Hi,
>
> im running mad about this: How is the "official" way to let the user 
> enter/choose a datetime (e.g. "2013-08-23 12:24") in a fluid form?
>
> If i set a default in the constructor
>
> class Foo extends AbstractEntity
> {
>     /**
>      * @var \DateTime
>      * @validate NotEmpty
>      */
>     protected $barTime;
>
>     public function __construct()
>     {
>         $this->barTime = new \DateTime();
>     }
> ...
>
> It is not possible for the user to change the dateTime with neither
>
> <f:form.textfield id=" barTime " property=" barTime " value="{foo.  
> barTime ->f:format.date()}" />
>
> nor
>
> <f:form.textfield id=" barTime " property=" barTime " />
>
> Can´t find any exapmles for that:-/ Do i habe to create a dummy field 
> and then set the user value in the controller?
>
> Regards, Hendrik
_______________________________________________
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