Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
* Popup save button state
* Empty table in survey view
* PHP 8 and empty checkbox group
  • Loading branch information
lsgs committed Sep 9, 2022
1 parent c05a5be commit c269e18
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
17 changes: 9 additions & 8 deletions InstanceTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,20 +342,21 @@ protected function makeHtmlTable($repeatingFormDetails, $canEdit) {
// if survey form get data now (as have no auth for an ajax call)
if ($this->isSurvey) {
$filter = "[$linkField]='$linkValue'";
$html.='<tbody>';
$instanceData = $this->getInstanceData($this->record, $eventId, $formName, $varList, $filter, false);
if (count($instanceData)===0) {
$html.='<tr><td colspan="'.$nColumns.'">No data available in table</td></tr>';
} else {
if (count($instanceData) > 0) {
$html.='<tbody>';
foreach ($instanceData as $rowValues) {
$html.='<tr>';
foreach ($rowValues as $value) {
$html.="<td>$value</td>";
}
$html.='</tr>';
}
$html.='</tbody>';
} else {
// $html.='<tr><td colspan="'.$nColumns.'">No data available in table</td></tr>';
// unnecessary and DT does not supprt colspan in bidy tr // https://datatables.net/forums/discussion/32575/uncaught-typeerror-cannot-set-property-dt-cellindex-of-undefined
}
$html.='</tbody>';
}

$html.='</table>';
Expand Down Expand Up @@ -388,7 +389,7 @@ public function getInstanceData($record, $event, $form, $fields, $filter, $inclu
$thisInstanceValues[] = $this->makeInstanceNumDisplay($instance, $record, $event, $form, $instance);

foreach ($instanceFieldData as $fieldName => $value) {
if (trim($value)==='') {
if (is_string($value) && trim($value)==='') { // PHP 8 doesn't like trimming checkbox array!
$thisInstanceValues[] = '';
continue;
}
Expand Down Expand Up @@ -709,7 +710,7 @@ protected function popupViewTweaks() {
}

// changes to save/cancel/delete buttons in popup window
$('button[name=submit-btn-saverecord]')// Save & Close
$('button[name=submit-btn-saverecord]')// Save & Exit Form (here means save and close the popup)
.removeAttr('onclick')
.click(function(event) {
$('#form').append('<input type="hidden" name="extmod_closerec_home" value="<?=$record?>">');
Expand All @@ -718,7 +719,7 @@ protected function popupViewTweaks() {
dataEntrySubmit(this);
});
$('#submit-btn-savenextinstance')// Save & Next Instance (not necessarily a new instance)
.attr('name', 'submit-btn-savecontinue')
.attr('name', 'submit-btn-savenextinstance')
.removeAttr('onclick')
.click(function(event) {
var currentUrl = window.location.href;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ If project is longitudinal, use `@INSTANCETABLE=event_name:form_name` to specify
* `@INSTANCETABLE_HIDEADD`: Suppress the "Add New" button.
* `@INSTANCETABLE_PAGESIZE`: Override default choices for page sizing: specify integer default page size, or -1 for "All".
* `@INSTANCETABLE_HIDEINSTANCECOL`: Hide the "#" column containing instance numbers.
* `@INSTANCETABLE_VARLIST=rptfrmvar1,rptfrmvar2`: Include only the variables from the repeating form that appear in the comma-separated list. (An alternative to using `@INSTANCETABLE_HIDE` for repeating form variables. `@INSTANCETABLE_HIDE` takes precedence where both used.)
* `@INSTANCETABLE_VARLIST=rptfrmvar1,rptfrmvar2,rptfrm_complete`: Include only the variables from the repeating form that appear in the comma-separated list. (An alternative to using `@INSTANCETABLE_HIDE` for repeating form variables. `@INSTANCETABLE_HIDE` takes precedence where both used.)
* `@INSTANCETABLE_REF=fieldname`: Where you have an instance table on a repeating form - i.e. is referencing another repeating form - you can have the instances filtered to show only those where the current instance number is saved in a field on the other form.<br>For example, an instance table in a repeating "Visit" form may be configured to show only instances of the repeating "Medication" form where the current Visit instance is selected in the `visitref` field on the Medication form: `@INSTANCETABLE @INSTANCETABLE_REF=visitref`.<br>Note that if you use `@INSTANCETABLE_REF` for an instance table on a non-repeating form the filter will default to `<ref field>=1`.<br>New instances created by clicking the "Add New" button below the instance table will have the current visit instance pre-selected.

### Tags Used for Fields on a Repeating Form
Expand Down

0 comments on commit c269e18

Please sign in to comment.