Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Adding attributes to fieldsets. Legends are optional for fieldsets. #5623

Closed
wants to merge 2 commits into from
Closed

Conversation

gammamatrix
Copy link
Contributor

As the comment says: Every collection is wrapped by a fieldset if needed

With this patch, a legend is not required for a fieldset.

  • Now, if a label is specified, a legend will be created.
  • Before, a fieldset would not be wrapped around the markup unless a label was set.
  • Now, a fieldset will be wrapped around the markup if $this->shouldWrap is true, regardless if a label has been set for the legend.

As the comment says: Every collection is wrapped by a fieldset if needed

A legend is not required for a fieldset.
* Now, if a label is specified, a legend will be created.
* Before, a fieldset would not be wrapped around the markup unless a label was set.
* Now, a fieldset will be wrapped around the markup if $this->shouldWrap is true, regardless if a label has been set for the legend.
@gammamatrix
Copy link
Contributor Author

It failed a test because of a space:

Failed asserting that '<form action="" method="POST" name="login-form" id="login-form"><fieldset ><label><span>Name of the city</span><input name="city[name]" type="text" value=""></label><label><span>ZipCode of the city</span><input name="city[zipCode]" type="text" value=""></label><fieldset ><legend>Country</legend><label><span>Name of the country</span><input name="city[country][name]" type="text" value=""></label><label><span>Continent of the city</span><input name="city[country][continent]" type="text" value=""></label></fieldset></fieldset><input type="submit" name="send" value=""></form>' contains "<fieldset><legend>Country</legend>".

contains "<fieldset><legend>Country</legend>"

Has an extra space to accomodate fieldset attributes.

<fieldset ><legend>Country</legend>

This was in test: ZendTest\Form\View\Helper\FormTest::testRender

@gammamatrix
Copy link
Contributor Author

Here is a similar patch against 2.3:

#5238

@Maks3w
Copy link
Member

Maks3w commented Jan 2, 2014

Add a unit test for the changes that you've made.

  • Fieldset without legend
  • Set attributes.


$markup = sprintf(
'<fieldset %s>%s%s</fieldset>',
$this->createAttributesString($attributes),
Copy link
Member

Choose a reason for hiding this comment

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

If you call createAttributesString() prior to the sprintf call, you can prefix the string with a space if it's non-empty. This will prevent the need to have a <fieldset > declaration.

@weierophinney weierophinney modified the milestones: 2.3.0, 2.2.6 Mar 3, 2014
@weierophinney weierophinney self-assigned this Mar 3, 2014
weierophinney added a commit that referenced this pull request Mar 3, 2014
Adding attributes to fieldsets. Legends are optional for fieldsets.
weierophinney added a commit that referenced this pull request Mar 3, 2014
- Added tests covering the various use cases:
  - fieldset without attributes
  - fieldset with attributes
  - fieldset without label
  - fieldset with label renders as legend
- Fixed code submission to only provide attributes in opening fieldset
  tag *IF* present
weierophinney added a commit that referenced this pull request Mar 3, 2014
Forward port #5623

Conflicts:
	library/Zend/Form/View/Helper/FormCollection.php
	tests/ZendTest/Form/View/Helper/FormCollectionTest.php
@weierophinney
Copy link
Member

@gammamatrix I made the changes requested on merge; a similar change was already on the develop branch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants