Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Symfony 3 #36

Merged
merged 13 commits into from
Apr 29, 2017
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ language: php
php:
- 5.3
- 5.4
- 5.5
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would still run builds with older still supported PHP versions to be sure to not introduce any regressions.


env:
- SYMFONY_VERSION=v2.3.3
- SYMFONY_VERSION=v2.8
- SYMFONY_VERSION=origin/master

before_script:
Expand Down
6 changes: 3 additions & 3 deletions Form/Type/DatetimeType.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/*
* This file is part of the SCDatetimepickerBundle package.
* This file is part of the DatetimepickerBundle package.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks wrong to me

*
* (c) Stephane Collot
*
Expand Down Expand Up @@ -46,7 +46,7 @@ class DatetimeType extends AbstractType
*
* @param array $options
*/
public function __construct(array $options)
public function __construct(array $options = array())
{
$this->options = $options;

Expand Down Expand Up @@ -164,7 +164,7 @@ public function getParent()

public function getName()
{
return 'collot_datetime';
return $this->getBlockPrefix();
}

public function getBlockPrefix()
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function registerBundles()
{
$bundles = array(
// ...
new SC\DatetimepickerBundle\SCDatetimepickerBundle(),
new SC\DatetimepickerBundle\DatetimepickerBundle(),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be referted too

);
}
```
Expand All @@ -59,14 +59,16 @@ $ php app/console assets:install web/
``` php
<?php
// ...
use SC\DatetimepickerBundle\Form\Type\DatetimeType;

public function buildForm(FormBuilder $builder, array $options)
{
$builder
// defaut options
->add('createdAt', 'collot_datetime')
->add('createdAt', DatetimeType::class)

// full options
->add('updatedAt', 'collot_datetime', array( 'pickerOptions' =>
->add('updatedAt', DatetimeType::class, array( 'pickerOptions' =>
array('format' => 'mm/dd/yyyy',
'weekStart' => 0,
'startDate' => date('m/d/Y'), //example
Expand Down
4 changes: 3 additions & 1 deletion Resources/views/Form/stylesheet_layout.html.twig
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
{% block form_stylesheet %}
{% spaceless %}
{% for child in form %}
{{ form_stylesheet(child) }}
{% if child.vars.pickerOptions is defined %}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The option should never be undefined.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

covers all fields, the other fields do not have the option

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I mean is that with this change the needed CSS files will never be loaded in case the form type provided by this bundle is nested in the form type tree as the block doesn't descend the structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand, I look

{{ form_stylesheet(child) }}
{% endif %}
{% endfor %}
{% endspaceless %}
{% endblock form_stylesheet %}
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
}
],
"require": {
"php": ">=5.3",
"symfony/framework-bundle": "2.*",
"symfony/symfony": "2.*"
"php": ">=5.3.9",
"symfony/framework-bundle": "~2.8 || ~3.0",
"symfony/symfony": "~2.8 || ~3.0"
},
"autoload": {
"psr-0": {
Expand Down