jgleixner
(Jörg Gleixner)
May 31, 2020, 2:15pm
1
Hi,
I get the following error when using a DateTime form field:
Could not convert target type “DateTime”: No converter found which can be used to convert from “__PHP_Incomplete_Class” or “object” to “DateTime”.
root<Neos.Fusion:Case>/ documentType<Neos.Fusion:Matcher>/ element<DigiPublica.Site:Document.Page>/ body<DigiPublica.Site:Component.DefaultLayout>/ content<Neos.Fusion:Component>/ main<Neos.Neos:ContentCollection>/ content<Neos.Neos:ContentCollectionRenderer>/ itemRenderer<Neos.Neos:ContentCase>/ default<Neos.Fusion:Matcher>/ element<Neos.Form.Builder:NodeBasedForm><Neos.Form.Builder:NodeBasedForm>/
packages:
neos/flow 6.2
neos/neos 5.2.1
neos/form 5.0.4
neos/form-builder 2.0.0
default preset
Auszug error log:
Exception #1297759968 in line 118 of /html/neos5/Data/Temporary/Development/Cache/Code/Flow_Object_Classes/Neos_Form_ViewHelpers_Form_DatePickerViewHelper.php: Could not convert target type “DateTime”: No converter found which can be used to convert from “__PHP_Incomplete_Class” or “object” to “DateTime”.
77 Neos\Flow\Property\PropertyMapper_Original::convert(__PHP_Incomplete_Class, “DateTime”)
76 Neos\Form\ViewHelpers\Form\DatePickerViewHelper_Original::getSelectedDate()
75 Neos\Form\ViewHelpers\Form\DatePickerViewHelper_Original::render()
74 call_user_func(array|2|)
Content of _PHP_Incomplete_Class:
[__PHP_Incomplete_Class_Name] => DateTime
[date] => 2020-05-30 19:45:51.000000
[timezone_type] => 3
[timezone] => Europe/Berlin
Many thanks for your help.
fleigm
(Michael Fleig)
June 4, 2020, 12:06pm
2
Hello Jörg,
I’ve had the same problem and solved it by manually casting the DateTime object to a string inside the DatePicker form element.
Im using the Form FusionRenderer package:
prototype(Neos.Form:DatePicker) < prototype(Neos.Form.FusionRenderer:FormElement) {
fieldContainer {
field {
tagName = 'input'
attributes {
type = 'date'
name = ${elementName}
// cast DateTime object to string
value = ${elementValue ? Date.format(elementValue, 'Y-m-d') : ''}
}
}
}
}
I hope this is helpful to you.
jgleixner
(Jörg Gleixner)
June 6, 2020, 10:19pm
3
Hello Michael,
thank you for posting your solution and sorry for the late response. Unfortunatelly it does not work for me. Im getting another error:
119 Neos\Flow\Error\ErrorHandler::handleError(8, "Object of class __PHP_Incomplete_Class could not be converted to int", "/html/neos5/Data/Temporary/Development/Cache/Code/…Flow_Object_Classes/Neos_Eel_Helper_DateHelper.php", 67, array|2|)
118 Neos\Eel\Helper\DateHelper_Original::format(__PHP_Incomplete_Class, "Y-m-d")
117 call_user_func_array(array|2|, array|2|)
116 Neos\Eel\Context::call("format", array|2|)
115 Neos\Eel\ProtectedContext::call("format", array|2|)
114 Neos\Eel\Context::callAndWrap("format", array|2|)
113 Neos\Eel\CompilingEvaluator_Original::{closure}(Neos\Eel\ProtectedContext)
112 Neos\Eel\CompilingEvaluator_Original::evaluateAndUnwrap(Closure, Neos\Eel\ProtectedContext)
111 Neos\Eel\CompilingEvaluator_Original::evaluate("elementValue ? Date.format(elementValue, 'Y-m-d') : ''", Neos\Eel\ProtectedContext)
110 Neos\Eel\Utility_Original::evaluateEelExpression("${elementValue ? Date.format(elementValue, 'Y-m-d') : ''}", Neos\Eel\CompilingEvaluator, array|29|)
109 Neos\Fusion\Core\Runtime_Original::evaluateEelExpression("${elementValue ? Date.format(elementValue, 'Y-m-d') : ''}", Neos\Fusion\FusionObjects\DataStructureImplementation)