mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
re-introduce post_text extension in fields.html.twig + tests
This commit is contained in:
parent
8849d8bb54
commit
f145ae7f88
@ -80,5 +80,29 @@
|
||||
</script>
|
||||
{% endblock cf_choices_row %}
|
||||
|
||||
{# extend the number type to add post_text extension #}
|
||||
{% block number_widget %}
|
||||
{%- if post_text is defined and post_text is not empty-%}
|
||||
<div class="input_with_post_text">
|
||||
{%- endif -%}
|
||||
{{ block('form_widget') }}
|
||||
{%- if post_text is defined and post_text is not empty-%}
|
||||
<span class="post_text">{{ post_text }}</span>
|
||||
</div>
|
||||
{%- endif -%}
|
||||
{% endblock %}
|
||||
|
||||
{# extend the number type to add post_text extension #}
|
||||
{% block integer_widget %}
|
||||
{%- if post_text is defined and post_text is not empty-%}
|
||||
<div class="input_with_post_text">
|
||||
{%- endif -%}
|
||||
{{ block('form_widget') }}
|
||||
{%- if post_text is defined and post_text is not empty-%}
|
||||
<span class="post_text">{{ post_text }}</span>
|
||||
</div>
|
||||
{%- endif -%}
|
||||
{% endblock %}
|
||||
|
||||
{# The choice_with_other_widget widget is defined in the main bundle #}
|
||||
|
||||
|
58
Tests/Form/Extension/PostTextIntegerExtensionTest.php
Normal file
58
Tests/Form/Extension/PostTextIntegerExtensionTest.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 Champs-Libres <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Chill\CustomFields\Tests\Form\Extension;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* Test the post-text extension
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class PostTextIntegerExtensionTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var \Symfony\Component\Form\FormBuilderInterface
|
||||
*/
|
||||
private $formBuilder;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$container = self::$kernel->getContainer();
|
||||
|
||||
$this->formBuilder = $container->get('form.factory')
|
||||
->createBuilder('form', null);
|
||||
}
|
||||
|
||||
public function testCreateView()
|
||||
{
|
||||
$form = $this->formBuilder->add('test', 'integer', array(
|
||||
'post_text' => 'my text'
|
||||
))->getForm();
|
||||
|
||||
$view = $form->createView();
|
||||
|
||||
$this->assertEquals('my text', $view['test']->vars['post_text']);
|
||||
}
|
||||
|
||||
}
|
58
Tests/Form/Extension/PostTextNumberExtensionTest.php
Normal file
58
Tests/Form/Extension/PostTextNumberExtensionTest.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 Champs-Libres <info@champs-libres.coop>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace Chill\CustomFields\Tests\Form\Extension;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
|
||||
/**
|
||||
* Test the post-text extension
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class PostTextNumberExtensionTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var \Symfony\Component\Form\FormBuilderInterface
|
||||
*/
|
||||
private $formBuilder;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$container = self::$kernel->getContainer();
|
||||
|
||||
$this->formBuilder = $container->get('form.factory')
|
||||
->createBuilder('form', null);
|
||||
}
|
||||
|
||||
public function testCreateView()
|
||||
{
|
||||
$form = $this->formBuilder->add('test', 'number', array(
|
||||
'post_text' => 'my text'
|
||||
))->getForm();
|
||||
|
||||
$view = $form->createView();
|
||||
|
||||
$this->assertEquals('my text', $view['test']->vars['post_text']);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user