ModelAdmin for Time fields --> 500 internal server error

Silverstripe Version: 4.5.1

Question:
Is there a bug if I want to manage a Time field with ModelAdmin? I get a 500 internal server error, but could not find any issue or bug report regarding this. How can I avoid the error message?

I have a model with a Time field:

namespace SFK\Model {

    use SilverStripe\ORM\DataObject;

    class Venue extends DataObject {
        private static $table_name = 'sfk_venue';

        private static $db = array(
            'Title' => 'Varchar(100)',
            'DefaultStartTime' => 'Time', // <-- This is the problem
            'Description' => 'HTMLText',
        );
        private static $summary_fields = ['Title'];
    }
}

This model should be managed using ModelAdmin:

use SilverStripe\Admin\ModelAdmin;

class MyAdmin extends ModelAdmin {

    private static $managed_models = [
        \SFK\Model\Venue::class,
    ];

    private static $url_segment = 'myadmin';

    private static $menu_title = 'My Admin';
}

When I add or edit a venue in the admin backend, a popup with “Internal Server Error” is displayed. The server response is:

[Warning] IntlDateFormatter::parse(): Date parsing failed
POST /sfk7/admin/myadmin/SFK-Model-Venue/EditForm/field/SFK-Model-Venue/item/1/ItemEditForm/

Line  393  in  F:\xampp_php7-2\htdocs\sfk7\vendor\silverstripe\framework\src\Forms\TimeField.php

Source

384      * @return string The formatted time, or null if not a valid time
385      */
386     protected function frontendToInternal($time)
387     {
388         if (!$time) {
389             return null;
390         }
391         $fromFormatter = $this->getFrontendFormatter();
392         $toFormatter = $this->getInternalFormatter();
393         $timestamp = $fromFormatter->parse($time);
394 
395         // Try to parse time without seconds, since that's a valid HTML5 submission format
396         // See https://html.spec.whatwg.org/multipage/infrastructure.html#times
397         if ($timestamp === false && $this->getHTML5()) {
398             $fromFormatter->setPattern(str_replace(':ss', '', DBTime::ISO_TIME));
399             $timestamp = $fromFormatter->parse($time);

Trace
... (a long trace; I can add it if someone is interested in it)

Nevertheless the data is saved in the database. Can anyone help me, how to avoid the internal server error popup? It is not very “user-friendly”. Thanks!

It’s possibly an issue with the php-intl library. Make sure that it’s installed and configured properly.

1 Like

Thanks for your quick response!

I enabled intl during installation, but didn’t adjust the error_level. For everyone else with the problem: In the php.ini I changed the line

intl.error_level = E_WARNING

to

intl.error_level = 0

Now everything is working. Thanks again for the hint to the intl configuration.