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 3480862
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T10:23:33+00:00 2026-05-18T10:23:33+00:00

I need to have a start and end time widget on a form. i.e.

  • 0

I need to have a start and end time widget on a form.

i.e. the user selects a date and then selects the start and end time.

In the standard date widget, you can select a date and a time, however I need to be able to select a finish time too.

Have any of you done it before?

I could create 3 separate widgets:

  • Date
  • Start Time
  • End Time

When the form is saved, I’ll do an update on the object to combine all values into one. For example, I’ll get the date and add the start time to it and then save to the field “start_date” and then I’ll get the date and add the end time to it and then save to the field “end_date”. It does however seem a very long winded way to do something which should be fairly trivial for a form framework.

Is this how you’d do it? Thanks guys!

  • 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-18T10:23:33+00:00Added an answer on May 18, 2026 at 10:23 am

    I think what you want to want achieve with symfony forms is pretty easy. You are right, you need three separate widgets and three separate validators, there isn’t an out of the box solution for this exact situation.

    In your form configure method you would have something like:

    $this->setWidgets(array(
      'date' => new sfWidgetFormDate(),
      'time_start' => new sfWidgetFormTime(array('label' => 'Start Time', 'with_seconds' => false)),
      'time_finish' => new sfWidgetFormTime(array('label' => 'End Time', 'with_seconds' => false)
    ));
    
    $this->setValidators(array(
      'date' => new sfValidatorDate(),   // by default outputs in format Y-m-d
      'time_start' => new sfValidatorTime(),  // by default outputs in format H:i:s
      'time_finish' => new sfValidatorTime(),
    ));
    

    Let’s assume that the object has two properties, as you suggested, both are datetime fields.

    In your action you would have something like the following to set the datetime fields:

    $values = $this->form->getValues();
    
    $object->setStartDateTime(sprintf('%s %s', $values['date'], $values['time_start']));
    $object->setFinishDateTime(sprintf('%s %s', $values['date'], $value['time_finish']));
    

    Edit: another suggestion is not use the built in time widget sfWidgetFormTime as it can look pretty ugly. You can simply use a normal text box (centre aligned, with maxlength=5), and the sfValidatorTime validator will still work perfectly.

    Hope that helps.

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

Sidebar

Related Questions

Have a form where a user can enter start date/time and end date/time for
I have two tables, both with start time and end time fields. I need
I have start date and end date. I need to find out the day
I have start time and end time in my application. I now need to
Hi I have a Start Date and End Date per record in a db.
I've a requirement in which I have a start and End time. For instance
I need to start NSTimer by 0:0:0 that I am doing and I have
I have a few servers and other daemons I need to start up in
I need change background of all text that have two spaces from the start
Here I have 2 requirements: Need a batch file to start a process on

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.