Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7612333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:53:02+00:00 2026-05-31T01:53:02+00:00

I would like to make a date clearable in a form (for example, with

  • 0

I would like to make a date clearable in a form (for example, with a little cross). The date field is already filled and I want to clear data. Is there an easy way to do this ?
My date is nullable and the option is set to ‘required’=>false.

Here is the form class :

// Namespaces...
class FormRre extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {
        // Other $builder->add() properties...

        $builder->add('rredatefin', 'date', array('required' => false));
    }

    public function getName()
    {
        return 'sn';
    }

    public function getDefaultOptions(array $options)
    {
        return array(
            'data_class' => 'Creasixtine\AFBundle\Entity\Rre',
        );
    }
}

And here is the way it is currently displayed :

{% extends 'CreasixtineAFBundle:Default:index.html.twig' %}

{% block main_container %}
{# ... #}
<form action="{{ path('planifier') }}" method="post" {{ form_enctype(form) }}>
    {{ form_errors(form) }}
    <div class="bloc-input">{{ form_label(form.rredatefin, "Date de réexpédition :") }}
    {{ form_widget(form.rredatefin) }}
    </div>

    <input type="submit" />
</form>
{% endblock %}

Thanks by advance.

EDIT : precisions in answer to How to clear a date in a form (Symfony2)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T01:53:04+00:00Added an answer on May 31, 2026 at 1:53 am

    I’m not quite sure to understand.

    If you made your date nullable and not required, just leave the field empty.
    It should be enough.
    Am I missing something ?

    After comment edit

    I’d advice you, as usual, to work with jquery.

    And the .val() function in particular.
    => http://api.jquery.com/val/

    $('#Devis_tarif_bi_horaire_select').change(function()
    {
        $('#Devis_tarif_bi_horaire_value').val('')
    });
    

    For instance, this little script will clear the input with id=Devis_tarif_bi_horaire_value when a select with id=Devis_tarif_bi_horaire_select is modified.
    You may trigger the .val() function with a click on a link (http://api.jquery.com/click/), or anything you want.

    Have a nice try.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Excel I have a date field. I would like to make a button
I would like to make a MySQL query, ordered sequentially by date. How would
I would like to make the code more efficient. The example creates a vector
I would like make an extension method for the generic class A which takes
Would like to make anapplication in Java that will not automatically parse parameters used
I would like to make a nightly cron job that fetches my stackoverflow page
I would like to make an ajax call to a different server (same domain
I would like to make a child class that has a method of the
I would like to make a list of remarkable robot simulation environments including advantages
I would like to make the update of the web application as automated as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.