Adding labels to data displayed in Confirmation Section of Form Entry UI

OpenMRS Reference Application 2.3:

Question: I’m trying to add labels to the summary details displayed in the confirmation section of the Form Entry UI. When each input is placed in it’s own fieldset this displays okay in the summary, but when all inputs are placed in one fieldset I get a comma separated list of the input values.

From this line it seems like one should be able to provide a label for the summary details by specifying a label element whose for attribute is the same as the input's id attribute. The snippet below should work okay, but it does not. How do I make this work?

<p class="left">
    <label for="stay-field">Stay</label>
    <input type="text" id="stay-field" >
</p>

I think I might have found a bug, but need confirmation. I believe the reason the labels are not being selected is because the jQuery selector for the label is not properly formed.

This:

this.label = $('label[for="' + this.element.attr('id') + ', "], 
label[for="' + this.element.parent().attr('id') + '"]').text().trim();

Should be changed to:

this.label = $('label[for="' + this.element.attr('id') + ' "], 
label[for="' + this.element.parent().attr('id') + '"]').text().trim();

Notice the comma in the original snippet for the first selector, it evaluates to something like label[for="stay-field,"] and this won’t match <label for="stay-field"></label>

@gwasilwa you may be right about the extra comma causing problems.

That said, please see here for a description of the expected behavior (and how to apply custom display): https://wiki.openmrs.org/x/HgGSB#SimpleFormUI-DisplayinConfirmation

Thanks @darius, though was hoping to use the default display provided by setting fieldset class to multi-line-confirmation.

Ah, I didn’t know about this feature.

It looks like @mogoodrich added it in this commit while implementing a Lab form for Mirebalais.

Mark, can you verify that @gwasilwa has found a bug, and also document multi-line-confirmation on the Simple Form UI wiki page?

This does look like a bug, thanks @gwasilwa!

Can you create a quick ticket for this (in the uicommons JIRA project) and I’ll push up the fix for it?

I will also look into updating the wiki page, thanks @darius.

Take care, Mark

@mogoodrich here is the ticket: https://issues.openmrs.org/browse/UICM-70.

Great, thanks @gwasilwa. I just pushed up the fix (removing the comma) that should hopefully resolve the issue.