Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Closed legend cause problem with form validation #8300

Closed
netzarbeiter opened this issue Apr 5, 2016 · 14 comments
Closed

Closed legend cause problem with form validation #8300

netzarbeiter opened this issue Apr 5, 2016 · 14 comments
Assignees
Labels
Milestone

Comments

@netzarbeiter
Copy link
Member

If a legend with mandatory fields is closed by default there is a problem with form validation.

Legend closed:
legend_closed

Legend opened:
legend_opened

@leofeyer
Copy link
Member

leofeyer commented Apr 5, 2016

Legends should always be open if they contain mandatory fields. Can the issue be reproduced in the online demo?

@aschempp
Copy link
Member

aschempp commented Apr 5, 2016

Well you can manually close them…

@netzarbeiter
Copy link
Member Author

You can reproduce it in the online demo.

  • Add a new content element «Hyperlink»
  • Close «Hyperlink settings»
  • Save

@leofeyer
Copy link
Member

leofeyer commented Apr 5, 2016

Well you can manually close them…

See https://youtu.be/aqAuuSo_p8M?t=90

@aschempp
Copy link
Member

aschempp commented Apr 5, 2016

That only works after reload, which does not happen with browser validation…

@fritzmg
Copy link
Contributor

fritzmg commented Apr 5, 2016

Sections with mandatory fields should be opened again via JavaScript before the form is submitted.

@leofeyer
Copy link
Member

leofeyer commented Apr 5, 2016

@aschempp Don't know if you have listened, but the video clearly says:

… also recognizes mandatory fields and makes sure that they are never inside a collapsed section.

@fritzmg
Copy link
Contributor

fritzmg commented Apr 5, 2016

@leofeyer the problem occurs when the user collapses a section manually (see netzarbeiter's reproduction steps). The video only states, that sections are always uncollapsed if there are mandatory fields in them when a record is opened. This works as expected. However, this is not what this issue is about.

@leofeyer
Copy link
Member

leofeyer commented Apr 5, 2016

@fritzmg The initial description is:

If a legend with mandatory fields is closed by default

So I don't think it is about manual collapsing. But it actually does not matter, because Contao should never collapse a section containing mandatory fields – no matter if the section was closed by default or manually.

@leofeyer leofeyer added the defect label Apr 5, 2016
@leofeyer leofeyer added this to the 3.5.10 milestone Apr 5, 2016
@fritzmg
Copy link
Contributor

fritzmg commented Apr 5, 2016

But it actually does not matter, because Contao should never collapse a section containing mandatory fields – no matter if the section was closed by default or manually.

I don't agree with that. I often collapse sections, regardless of whether they contain mandatory fields or not, while I create or edit a record which has a lot of sections, to get a better overview. Imho it would be detrimental to the user experience if you suddenly disallow the collapse of sections containing mandatory fields.

@Toflar
Copy link
Member

Toflar commented Apr 5, 2016

Yeah, I think opening them before the form is submitted, makes more sense.

@leofeyer
Copy link
Member

leofeyer commented Apr 5, 2016

I often collapse sections, regardless of whether they contain mandatory fields or not

Yes, but only if those fields contain a value. Otherwise collapsing does not make any sense at all, because not filling in the fields will lead to an error message upon submit.

Therefore Contao will always open sections if there are empty mandatory fields.

@fritzmg
Copy link
Contributor

fritzmg commented Apr 5, 2016

Yes, but only if those fields contain a value. Otherwise collapsing does not make any sense at all, because not filling in the fields will lead to an error message upon submit.

No, I meant I collapse all fields and open them one by one while creating/editing a record. Just because I collapse a section does not necessarily mean I do not intend to enter any values in the contained fields while editing/creating a record.

Therefore Contao will always open sections if there are empty mandatory fields.

Do you mean when loading an entry? Yes, that currently works as expected and does not need to be changed. I was concerned you want to remove the functionality to be able to collapse sections containing mandatory fields altogether.

The issue here only arises if you manually collapse a section containing a mandatory field and then click any of the [type="submit"] buttons. Thus the solution would be to simply do something like this (jQuery version):

$('.tl_submit_container [type="submit"]').click(function(){
    $(this).parents('form').find('fieldset').each(function(){
        if($(this).find('[required]').length > 0){
            // un-collapse this fieldset
        }
    });
});

@leofeyer
Copy link
Member

Fixed in 36fbc41.

leofeyer added a commit to contao-components/contao that referenced this issue Apr 21, 2016
jsonn pushed a commit to jsonn/pkgsrc that referenced this issue Apr 23, 2016
### 4.1.3 (2016-04-22)

 * Use data URIs for the image preview in the back end.
 * Use DIRECTORY_SEPARATOR to convert kernel.cache_dir into a relative path (see #464).
 * Always trigger the "isVisibleElement" hook (see contao/core#8312).
 * Do not change all sessions when switching users (see contao/core#8158).
 * Do not allow to close fieldsets with empty required fields (see contao/core#8300).
 * Make the path related properties of the File class binary-safe (see contao/core#8295).
 * Correctly validate and decode IDNA e-mail addresses (see contao/core#8306).
 * Skip forward pages entirely in the book navigation module (see contao/core#5074).
 * Do not add the X-Priority header in the Email class (see contao/core#8298).
 * Determine the search index checksum in a more reliable way (see contao/core#7652).
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants