Render datetime field row

@access public

@param IFormModel $model model
@param string $property model property
@param array $options attribute array

@return string
191028
public function dateTimeFieldRow(IFormModel $model, $property, array $options = [])
    {
        $element = $this->getField($model, $property);
        $options['id'] = $element['id'];

        return Html::openTag('div', $this->getBlock('block', $options)).
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
        $this->dateTimeField($model, $property, $options).
        Html::closeTag('div');
    }
827568
public function render(array $data, ContextInterface $context)
    {
        $id = $data['id'];
        $name = $data['name'];
        $val = $data['val'];
        $type = $data['type'];
        $required = $data['required'] ? 'required' : '';
        $disabled = isset($data['disabled']) && $data['disabled'] ? 'disabled' : '';
        $role = isset($data['role']) ? $data['role'] : 'datetime-picker';
        $format = null;
        $locale = isset($data['locale']) ? $data['locale'] : I18n::getLocale();

        $timezoneAware = Configure::read('CrudView.timezoneAwareDateTimeWidget');

        $timestamp = null;
        $timezoneOffset = null;

        if (isset($data['data-format'])) {
            $format = $this->_convertPHPToMomentFormat($data['data-format']);
        }

        if (!($val instanceof DateTimeInterface) && !empty($val)) {
            switch ($type) {
                case 'date':
                case 'time':
                    $val = Type::build($type)->marshal($val);
                    break;

                default:
                    $val = Type::build('datetime')->marshal($val);
            }
        }

        if ($val && !is_string($val)) {
            if ($timezoneAware) {
                $timestamp = $val->format('U');
                $dateTimeZone = new DateTimeZone(date_default_timezone_get());
                $timezoneOffset = ($dateTimeZone->getOffset($val) / 60);
            }
            $val = $val->format($type === 'date' ? 'Y-m-d' : 'Y-m-d H:i:s');
        }

        if ($format === null) {
            if ($type === 'date') {
                $format = 'L';
            } elseif ($type === 'time') {
                $format = 'LT';
            } else {
                $format = 'L LT';
            }
        }

        $icon = $type === 'time'
            ? 'time'
            : 'calendar';

        $widget = <<<html
            <div class="input-group $type">
                <input
                    type="text"
                    class="form-control"
                    name="$name"
                    value="$val"
                    id="$id"
                    role="$role"
                    data-locale="$locale"
                    data-format="$format"
html;
        if ($timezoneAware && isset($timestamp, $timezoneOffset)) {
            $widget .= <<<html
                    data-timestamp="$timestamp"
                    data-timezone-offset="$timezoneOffset"
html;
        }
        $widget .= <<<html
                    $required
                    $disabled
                />
                <label for="$id" class="input-group-addon">
                    <span class="glyphicon glyphicon-$icon"></span>
                </label>
            </div>
html;

        return $widget;
    }
861752
public static function linkFormat($model, $attribute, $options = [])
    {
        return array_merge([
            'attribute' => $attribute,
            'format' => 'raw',
            'value' => !$model->isNewRecord
                ? Html::a($model->$attribute, ['view', 'id' => $model->primaryKey])
                : function ($data) use ($attribute) {
                    return Html::a($data->$attribute, ['view', 'id' => $data->primaryKey]);
                },
            'visible' => $model->isAttributeSafe($attribute),
        ], $options);
    }
555754
public function emailFieldRow(IFormModel $model, $property, array $options = [])
    {
        $element = $this->getField($model, $property);
        $options['id'] = $element['id'];

        return Html::openTag('div', $this->getBlock('block', $options)).
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
        $this->emailField($model, $property, $options).
        Html::closeTag('div');
    }
611079
protected function renderDateTime(DateTime $date = null, $format = DateTimeRenderer::DATETIME_FORMAT) {
        return DateTimeRenderer::renderDateTime($date, $format);
    }
448461
public function textAreaField(IFormModel $model, $property, array $options = [])
    {
        $element = $this->getField($model, $property);
        $options['id'] = $element['id'];

        return Html::textArea($element['name'], $element['value'], $options);
    }
29874
public function render(array $options = [])
    {
        $attrs['id'] = $this->getAttribute('controlId', $this->getId() . '-control');
        $attrs['class'] = $this->type . '-field ' . $this->getAttribute('controlClass');

        $attrs = array_merge($attrs, (array) $this->getAttribute('controlAttribs'));

        if ($this->form && $this->form->getRenderer()) {
            return $this->wrapElements($this->form->getRenderer()->renderField($this, $attrs, $options));
        }

        $label = !empty($options['no_label']) ? '' : $this->renderLabel($options);
        $input = $this->renderInput($options);

        return $this->wrapElements(new HtmlElement('div', $label . $input, $attrs));
    }
1113179
public function hiddenField(IFormModel $model, $property, array $options = [])
    {
        $element = $this->getField($model, $property);

        return Html::hiddenField($element['name'], $element['value'], $options);
    }
1213397
public function renderValueReader($property): string
    {
        if ($property instanceof VirtualPropertyMetadata) {
            $accessor = \sprintf('$object->%s()', $property->name);
        } elseif (null !== $property->getter) {
            $accessor = \sprintf('$object->%s()', $property->getter);
        } elseif ($property->reflection->isPublic()) {
            $accessor = \sprintf('$object->%s', $property->name);
        } else {
            $accessor = \sprintf('$this->classMetadata->propertyMetadata[\'%s\']->reflection->getValue($object)', $property->name);
        }

        return \strtr(self::$propertyReadTemplate, [
            '{propertyName}' => $property->name,
            '{accessor}' => $accessor,
            '{exposure}' => $this->createValueExposure($property),
        ]);
    }
814974
public function radioButtonListFieldRow(IFormModel $model, $property, array $options = [])
    {
        $element = $this->getField($model, $property);
        $options['id'] = $element['id'];

        return Html::openTag('div', $this->getBlock('block', $options)).
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
        $this->radioButtonListField($model, $property, $options).
        Html::closeTag('div');
    }
857501
public function renderRow($content, $type = null, $label = null, array $options = [])
    {
        $compound = false;

        if ($type == 'checkbox') {
            $content = $this->renderCheckboxWidget($content, $options);
        } elseif ($type == 'number') {
            $content = $this->renderNumberWidget($content, $options);
        } elseif ($type == 'textarea') {
            $content = $this->renderTextareaWidget($content, $options);
        } elseif ($type == 'entity') {
            $content = $this->renderEntityWidget($content, $options);
        } elseif ($type == 'url') {
            $content = $this->renderUrlWidget($content, $options);
        } elseif ($type == 'datetime' || $type == 'date') {
            if ($type == 'date') {
                $options['time'] = false;
            }
            $content = $this->renderDatetimeWidget($content, $options);
        } elseif ($type == 'tel') {
            $content = $this->renderTelWidget($content, $options);
        } elseif ($type == 'color') {
            $content = $this->renderColorWidget($content, $options);
        } elseif ($type == 'tinymce') {
            $content = $this->renderTinymceWidget($content, $options);
        } elseif ($type == 'upload') {
            $content = $this->renderUploadWidget($content, $options);
        } elseif ($type == 'media') {
            $content = $this->renderMediaWidget($content, $options);
        } elseif ($type == 'medias') {
            $content = $this->renderMediasWidget($content, $options);
        } elseif ($type == 'seo') {
            $content = $this->renderSeoWidget($content, $options);
        } elseif ($type == 'key_value_collection') {
            $content = $this->renderKeyValueCollectionWidget($content, $options);
        } elseif ($type == 'coordinate') {
            $content = $this->renderCoordinateWidget($content, $options);
        } else {
            $content = $this->renderSimpleWidget($content, $options);
        }

        $vars = [
            'label' => $label !== null ? $label : false,
            'content' => $content,
            'compound' => $compound
        ];

        /* Fix boostrap columns */
        $vars['label_nb_col'] = isset($options['label_nb_col']) ? intval($options['label_nb_col']) : (strlen($label) > 0 ? 2 : 0);
        $vars['nb_col'] = isset($options['nb_col']) ? intval($options['nb_col']) : 12 - $vars['label_nb_col'];

        return $this->renderBlock('show_row', $vars);
    }
383916
public function formatDate(DateTime $dateTime = null, $format = DateTimeRenderer::DATETIME_FORMAT) {
        return DateTimeRenderer::renderDateTime($dateTime, $format);
    }
169747
private function renderProperties(MetadataInterface $metadata, array $options)
    {
        $properties = array_replace_recursive(
            $options['defaults'],
            array_filter($metadata->toArray(), function ($item) { return null !== $item; })
        );

        $renderedProperties = [];
        foreach ($properties as $propertyKey => $propertyValue) {
            if (null === $propertyValue) {
                continue;
            }

            $this->ensurePropertyIsKnown($metadata, $propertyKey);

            $renderedProperties[] = sprintf(
                '<meta name="%s" content="%s" />',
                $this->keysToNames[$propertyKey],
                htmlentities($propertyValue, \ENT_COMPAT)
            );
        }

        return $renderedProperties;
    }
680405
protected function renderDatetimeWidget($content, array $options = [])
    {
        if (!array_key_exists('time', $options)) {
            $options['time'] = true;
        }
        if (!array_key_exists('date_format', $options)) {
            $options['date_format'] = 'short';
        }
        if (!array_key_exists('time_format', $options)) {
            $options['time_format'] = $options['time'] ? 'short' : 'none';
        }
        if (!array_key_exists('locale', $options)) {
            $options['locale'] = null;
        }
        if (!array_key_exists('timezone', $options)) {
            $options['timezone'] = null;
        }
        if (!array_key_exists('format', $options)) {
            $options['format'] = '';
        }

        $vars = [
            'content' => $content,
            'options' => $options,
        ];

        return $this->renderBlock('show_widget_datetime', $vars);
    }
308275
static public function renderField($value, array $options, $item)
    {
        if (empty($options['name'])) {
            return '';
        }
        if (empty($value) || !is_array($value)) {
            return '';
        }

        if (!$item instanceof EntityInterface) {
            return '';
        }

        $output = field_view_field($item->getEntityTypeId(), $item, $options['name'], self::LIST_VIEW_MODE);

        return drupal_render($output);
    }
529218
public function checkboxFieldRow(IFormModel $model, $property, array $options = [])
    {
        $element = $this->getField($model, $property);
        $options['id'] = $element['id'];

        return Html::openTag('div', $this->getBlock('block', $options)).
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
        $this->checkBoxField($model, $property, $options).
        Html::closeTag('div');
    }
11651
public function imageFieldRow(IFormModel $model, $property, array $options = [])
    {
        $element = $this->getField($model, $property);
        $options['id'] = $element['id'];

        return Html::openTag('div', $this->getBlock('block', $options)).
        Html::label($model->getLabel($property), $element['id'], $this->getBlock('label', $options)).
        $this->imageField($model, $property, $options).
        Html::closeTag('div');
    }