Available options: * widget: How to render the time field ("input" or "choice"). Default: "choice". * type: The type of the date stored on the object. Default: "datetime": * datetime: A DateTime object; * string: A raw string (e.g. 2011-05-01 12:30:00, Y-m-d H:i:s); * timestamp: A unix timestamp (e.g. 1304208000). * raw: An hour, minute, second array * with_seconds Whether or not to create a field for seconds. Default: false. * hours: An array of hours for the hour select tag. * minutes: An array of minutes for the minute select tag. * seconds: An array of seconds for the second select tag. * data_timezone: The timezone of the data. Default: UTC. * user_timezone: The timezone of the user entering a new value. Default: UTC.
Inheritance: extends Form
Esempio n. 1
0
 public function testSetData_differentTimezones()
 {
     $field = new TimeField('name', array('data_timezone' => 'America/New_York', 'user_timezone' => 'Pacific/Tahiti', 'type' => TimeField::STRING, 'with_seconds' => true));
     $dateTime = new \DateTime('03:04:05 America/New_York');
     $field->setData($dateTime->format('H:i:s'));
     $dateTime = clone $dateTime;
     $dateTime->setTimezone(new \DateTimeZone('Pacific/Tahiti'));
     $displayedData = array('hour' => (int) $dateTime->format('H'), 'minute' => (int) $dateTime->format('i'), 'second' => (int) $dateTime->format('s'));
     $this->assertEquals($displayedData, $field->getDisplayedData());
 }
 public function testIsPartiallyFilled_returnsTrueIfChoiceAndSecondsEmpty()
 {
     $field = new TimeField('name', array('widget' => 'choice', 'with_seconds' => true));
     $field->submit(array('hour' => '0', 'minute' => '0', 'second' => ''));
     $this->assertTrue($field->isPartiallyFilled());
 }
Esempio n. 3
0
    public function testRenderAsChoices_nonRequired()
    {
        $field = new TimeField('name', array('hours' => array(3, 4), 'minutes' => array(5, 6), 'widget' => TimeField::CHOICE, 'data_timezone' => 'UTC', 'user_timezone' => 'UTC'));
        $field->setRequired(false);
        $field->setData(new \DateTime('04:05 UTC'));
        $html = <<<EOF
<select id="name_hour" name="name[hour]" class="foobar">
<option value=""></option>
<option value="3">03</option>
<option value="4" selected="selected">04</option>
</select>:<select id="name_minute" name="name[minute]" class="foobar">
<option value=""></option>
<option value="5" selected="selected">05</option>
<option value="6">06</option>
</select>
EOF;
        $this->assertEquals($html, $field->render(array('class' => 'foobar')));
    }