New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preserveDefault in forms does not work for dateTimePicker objects #3612

ekeih opened this Issue Nov 8, 2018 · 1 comment


None yet
2 participants

ekeih commented Nov 8, 2018

During the OSMC Hackathon @lippserd and I discovered a bug in the Icingaweb2 core. We modified the ScheduleServiceDowntimeCommandForm.php file and added 'preserveDefault' => true to a dateTimePicker object:

        'required'        => true,
        'preserveDefault' => true,
        'label'           => $this->translate('End Time'),
        'description'     => $this->translate('Set the end date and time for the downtime.'),
        'value'           => $end

According to @lippserd this should work with a dateTimePicker object without an issue. Instead we got an error:

Warning: Exception caught by form: htmlspecialchars() expects parameter 1 to be string, object given Stack Trace: #0 [internal function]:
Icinga\Application\ApplicationBootstrap->Icinga\Application\{closure}(2, 'htmlspecialchar...', '/vagrant/librar...', 94, Array)
#1 /vagrant/library/vendor/Zend/Form/Decorator/HtmlTag.php(94): htmlspecialchars(Object(DateTime), 2, 'UTF-8') #2 /vagrant/library/vendor/Zend/Form/Decorator/HtmlTag.php(162): Zend_Form_Decorator_HtmlTag->_htmlAttribs(Array)
#3 /vagrant/library/vendor/Zend/Form/Decorator/HtmlTag.php(223): Zend_Form_Decorator_HtmlTag->_getOpenTag('input', Array)
#4 /vagrant/library/vendor/Zend/Form/Element.php(2048): Zend_Form_Decorator_HtmlTag->render('<div class="con...')
#5 /vagrant/library/vendor/Zend/Form/Decorator/FormElements.php(115): Zend_Form_Element->render()
#6 /vagrant/library/vendor/Zend/Form/DisplayGroup.php(914): Zend_Form_Decorator_FormElements->render('')
#7 /vagrant/library/vendor/Zend/Form/Decorator/FormElements.php(115): Zend_Form_DisplayGroup->render() in /vagrant/library/vendor/Zend/Form.php on line 2995

As a workaround we modified the value assertion:

'value'         => $end->format('Y-m-d\TH:i:s')

We worked on the current master and wanted to add functionality to the downtime form.

@ekeih ekeih changed the title from `'preserveDefault' => true` in forms does not work for dateTimePicker objects to preserveDefault in forms does not work for dateTimePicker objects Nov 8, 2018

@lippserd lippserd added the bug label Nov 8, 2018


This comment has been minimized.


lippserd commented Nov 8, 2018

Thanks for the issue 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment