Skip to content
This repository was archived by the owner on Aug 14, 2025. It is now read-only.

Latest commit

 

History

History
69 lines (52 loc) · 1.54 KB

File metadata and controls

69 lines (52 loc) · 1.54 KB

BeelabLapTypeBundle Documentation

1. Installation

Run from terminal:

$ composer require beelab/lap-type-bundle

Enable bundle in the kernel:

<?php
// app/AppKernel.php
public function registerBundles()
{
    $bundles = array(
        // ...
        new Beelab\LapTypeBundle\BeelabLapTypeBundle(),
    );
}

2. Configuration

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;
}

3. Usage in forms

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.

4. Template filter

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 %}