Skip to content

Commit f0176a9

Browse files
committed
feature #32061 Add new Form WeekType (dFayet)
This PR was merged into the 4.4 branch. Discussion ---------- Add new Form WeekType | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes <!-- please update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #32029 | License | MIT | Doc PR | <!--symfony/symfony-docs#...--> coming soon ---- #### Update After the first try, I've updated the field to have more options, and be more "straight". The field acts like the `DateTimeType` or `TimeType`, various fields type (pure text, html5 type, select boxes), data validation, .... For that I took the choice to update the `DateTimeToStringTransformer` and `DateTimeToArrayTransformer` to make them work with weeks format. I was not sure if it was better to update them or create new ones, WDYT? Before addind tests and docs, it would be nice to have your first thoughts/comments 😊 Do you need/want a small test repo? Commits ------- c4a2f026e0 Add new Form WeekType
2 parents 60aaf98 + ebadd56 commit f0176a9

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php if ($widget == 'single_text'): ?>
2+
<?php echo $view['form']->block($form, 'form_widget_simple'); ?>
3+
<?php else: ?>
4+
<?php $vars = $widget == 'text' ? ['attr' => ['size' => 1]] : [] ?>
5+
<div <?php echo $view['form']->block($form, 'widget_container_attributes') ?>>
6+
<?php
7+
// There should be no spaces between the colons and the widgets, that's why
8+
// this block is written in a single PHP tag
9+
echo $view['form']->widget($form['year'], $vars);
10+
echo '-';
11+
echo $view['form']->widget($form['week'], $vars);
12+
?>
13+
</div>
14+
<?php endif ?>

0 commit comments

Comments
 (0)