Project

General

Profile

Actions

Bug #88899

closed

DatePicker-Field used in finisher option fails with PHP-conversion Error

Added by Dirk Steffens over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Should have
Category:
Form Framework
Start date:
2019-08-02
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
10
PHP Version:
7.0
Tags:
DatePicker finisher parseOption DateTime CodingNight
Complexity:
medium
Is Regression:
Sprint Focus:
Remote Sprint

Description

A simple form with only a datepicker-field crashes in finisher:

#1476107295: PHP Catchable Fatal Error: Object of class DateTime could not be converted to string in /typo3_src/typo3/sysext/form/Classes/Domain/Finishers/AbstractFinisher.php line 319

In 'Subject' in (e.g.) emailFinisher there is a formelement identifier from the Datepicker-field together with a little bit other text in the same field.

This is the yaml-code of an example to reproduce it:

renderingOptions:
  submitButtonLabel: Submit
type: Form
identifier: datePickerTest
label: DatePickerTest
prototypeName: standard
finishers:
  -
    options:
      subject: 'prepend{datepicker-1}append'
      recipientAddress: recipient@anydomain.de
      recipientName: ''
      senderAddress: sender@anydomain.de
      senderName: ''
      replyToAddress: ''
      carbonCopyAddress: ''
      blindCarbonCopyAddress: ''
      format: html
      attachUploads: true
    identifier: EmailToSender
renderables:
  -
    renderingOptions:
      previousButtonLabel: 'Previous step'
      nextButtonLabel: 'Next step'
    type: Page
    identifier: page-1
    label: Step
    renderables:
      -
        properties:
          dateFormat: Y-m-d
          enableDatePicker: true
          displayTimeSelector: false
        type: DatePicker
        identifier: datepicker-1
        label: 'Date picker'

The Problem is with: subject: 'prepend{datepicker-1}append'
Without prepend / append- string this error does not happen. Instead there is another Error which is not discussed here.

Since the error happens in parseOption() it is usefull to replace the DateTime object with a Text-equivalent before calling parseOption().
This can be done with the following workaround:

foreach ($this->finisherContext->getFormValues() as $key => $formvalue){
    if (is_object($formvalue) && get_class($formvalue)=="DateTime"){
        $format = $this->finisherContext->getFormRuntime()->getFormDefinition()->getElementByIdentifier('from')->getProperties()['dateFormat'];
        $this->finisherContext->getFormRuntime()->getFormState()->setFormValue($key, $formvalue->format($format));
    }
}

Therfor one has to build an own finisher or to use a hook.

Actions #1

Updated by Susanne Moog over 4 years ago

  • Tags changed from DatePicker finisher parseOption DateTime to DatePicker finisher parseOption DateTime CodingNight
Actions #2

Updated by Björn Jacob over 4 years ago

Today, this issue was discussed on Slack within the #ext-form channel. Here's the link: https://typo3.slack.com/archives/C093RB4P9/p1564708838072600

It comes from a datepicker-element in the contact-form. Results in type DateTime. The debugger is just open to see this very clear.

Alright, that explains it. Apparently this usecase is not yet supported. You could work around this by manipulating the birthday form value to convert it into a date string (with your preferred format) before calling parseOption() for the message.
For this you can use $this->finisherContext->getFormRuntime()->getFormState()->setFormValue('birthday', $formattedDate).

Edit: I just realized that the author of the ticket is the same person who has discussed this on the channel :)

Actions #3

Updated by Pascal Naujoks over 4 years ago

  • Tracker changed from Feature to Bug
  • TYPO3 Version set to 8
  • PHP Version changed from 7.2 to 7.0

Can reproduce in TYPO3 8.7.27 when using the datepicker in the E-Mail finisher as the subject like "New reservation on {datepicker-1}"

Actions #4

Updated by Susanne Moog over 4 years ago

  • Sprint Focus set to Remote Sprint
Actions #5

Updated by Mathias Brodala over 4 years ago

First we need do clarify if something like this should be supported at all.

It surely would make sense but then the desired format cannot be defined on the DatePicker field but actually needs to be defined at the location where the value from such a field is used. Given that DatePicker field values could be used within strings just like in the example here, there is no good location to define the format ATM.

Actions #6

Updated by Mathias Brodala over 4 years ago

  • Status changed from New to In Progress
  • Assignee set to Mathias Brodala
Actions #7

Updated by Gerrit Code Review over 4 years ago

  • Status changed from In Progress to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62361

Actions #8

Updated by Gerrit Code Review over 4 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62361

Actions #9

Updated by Gerrit Code Review over 4 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62361

Actions #10

Updated by Gerrit Code Review over 4 years ago

Patch set 4 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62361

Actions #11

Updated by Gerrit Code Review over 4 years ago

Patch set 5 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62361

Actions #12

Updated by Gerrit Code Review over 4 years ago

Patch set 6 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62361

Actions #13

Updated by Ralf Zimmermann over 4 years ago

  • TYPO3 Version changed from 8 to 10
Actions #14

Updated by Gerrit Code Review over 4 years ago

Patch set 7 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62361

Actions #15

Updated by Gerrit Code Review over 4 years ago

Patch set 8 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62361

Actions #16

Updated by Gerrit Code Review over 4 years ago

Patch set 9 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/c/Packages/TYPO3.CMS/+/62361

Actions #17

Updated by Mathias Brodala over 4 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #18

Updated by Benni Mack over 4 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF