Skip to content
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

Closed
ekeih opened this issue Nov 8, 2018 · 1 comment
Closed

preserveDefault in forms does not work for dateTimePicker objects #3612

ekeih opened this issue Nov 8, 2018 · 1 comment
Assignees
Labels
area/framework Affects third party integration/development bug Something isn't working
Milestone

Comments

@ekeih
Copy link

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:

array(
    'dateTimePicker',
    'end',
    array(
        '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 'preserveDefault' => true in forms does not work for dateTimePicker objects preserveDefault in forms does not work for dateTimePicker objects Nov 8, 2018
@lippserd lippserd added the bug Something isn't working label Nov 8, 2018
@lippserd
Copy link
Member

lippserd commented Nov 8, 2018

Thanks for the issue 👍

@nilmerg nilmerg added this to the 2.6.3 milestone Apr 10, 2019
@nilmerg nilmerg self-assigned this Apr 16, 2019
@nilmerg nilmerg added the area/framework Affects third party integration/development label Apr 17, 2019
nilmerg added a commit that referenced this issue Apr 18, 2019
fixes #3612

(cherry picked from commit 3fe810e)
Signed-off-by: Johannes Meyer <johannes.meyer@icinga.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/framework Affects third party integration/development bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants