From 2b111998b585803602202109890b2a773255678b Mon Sep 17 00:00:00 2001 From: Laurent Laffont <llaffont@afi-sa.fr> Date: Wed, 21 Dec 2016 16:28:39 +0100 Subject: [PATCH] hotline #52410 form elements without label should be wrap with td colspan 2 --- library/ZendAfi/View/Helper/RenderForm.php | 10 ++++++++-- .../admin/controllers/AccueilControllerCmsTest.php | 12 ++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/library/ZendAfi/View/Helper/RenderForm.php b/library/ZendAfi/View/Helper/RenderForm.php index 2cd9b435387..7012d7e7b52 100644 --- a/library/ZendAfi/View/Helper/RenderForm.php +++ b/library/ZendAfi/View/Helper/RenderForm.php @@ -101,9 +101,15 @@ class ZendAfi_View_Helper_RenderForm extends ZendAfi_View_Helper_BaseHelper { switch ($name) { case 'label': + $input_tag_params = ['tag' => 'td', + 'class' => 'gauche']; + + if ( !trim($element->getLabel()) ) + $input_tag_params['colspan'] = 2; + $newDecorators[] = [['input_data' => 'HtmlTag'], - ['tag' => 'td', - 'class' => 'gauche']]; + $input_tag_params]; + $decorator->setOptions([]); $decorator->setOption('wrap', ['tag' => 'td', 'attribs' => ['class' => 'droite']]); diff --git a/tests/application/modules/admin/controllers/AccueilControllerCmsTest.php b/tests/application/modules/admin/controllers/AccueilControllerCmsTest.php index ad09ab69c83..9b78d439fcb 100644 --- a/tests/application/modules/admin/controllers/AccueilControllerCmsTest.php +++ b/tests/application/modules/admin/controllers/AccueilControllerCmsTest.php @@ -52,6 +52,18 @@ class Admin_AccueilControllerCmsWithDefaultDiaporamaNavigationTest extends Admin } + /** @test */ + public function inputIdItemsTDShouldHaveColspanTwo() { + $this->assertXPath('//td[@colspan="2"]//input[@name="id_items"]'); + } + + + /** @test */ + public function inputTitreTDShouldNotHaveColspan() { + $this->assertXPath('//td[not(@colspan)]//input[@name="titre"]'); + } + + /** @test */ public function inputIdItemsShouldContains1and2() { $this->assertXPath('//form//input[@name="id_items"][@value="1-2"]', $this->_response->getBody()); -- GitLab