Run from terminal:
$ composer require beelab/lap-type-bundleEnable bundle in the kernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new Beelab\LapTypeBundle\BeelabLapTypeBundle(),
);
}Insert in main configuration:
# app/config/config.yml
twig:
form:
resources:
- 'BeelabLapTypeBundle::lap_widget.html.twig'Since inputs are pretty large by default, you can use something like this in your stylesheet:
.lap input {
max-width: 70px;
}You can use the beelab_lap type in your forms. It will displays four number inputs for hours, minutes,
seconds and milliseconds. You can hide hours and/or milliseconds passing the options with_hours and/or
with_milliseconds with value false (default values are true).
The submitted value will be converted into an integer (the total milliseconds), so if you want to store that
value in a Doctrine entity, you can use an integer column type.
You can use the lap filter to nicely display your lap times (likely coming from a Doctrine entity).
Example:
{# your twig template #}
{% block body %}
{# will show something like 1:23:45.678 #}
Lap time: {{ entity.time|lap }}
{# will show something like 23:45.678 #}
Lap time without hours: {{ entity.time|lap(false) }}
{% endblock %}