Skip to content

Instantly share code, notes, and snippets.

@jmolivas
Last active December 24, 2015 10:29
Show Gist options
  • Save jmolivas/6784640 to your computer and use it in GitHub Desktop.
Save jmolivas/6784640 to your computer and use it in GitHub Desktop.
Override date & time inputs more info: How to customize Form Rendering - http://symfony.com/doc/current/cookbook/form/form_customization.html
{# File path: YourBundle / Resources / views / Form / fields.html.twig #}
{% block form_widget_simple %}
{% spaceless %}
{% set type = type|default('text') in ['date','time'] ? 'text' : type|default('text') %}
<input type="{{ type }}" {{ block('widget_attributes') }} {% if value is not empty %}value="{{ value }}" {% endif %}/>
{% endspaceless %}
{% endblock form_widget_simple %}
{# How to use: #}
# 1 Apply on a single Twig
{% form_theme form 'MytechdeskBundle:Form:fields.html.twig' %}
# 2 Making Application-wide Customizations¶
# app/config/config.yml
twig:
form:
resources:
- 'AcmeDemoBundle:Form:fields.html.twig'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment