Skip to content

Commit 5044e46

Browse files
committed
Merge branch 'bugfix/derived-topic-validation' into develop
Fixes a bug in which topics that derive from another topic still enforced required field validation, thus preventing required fields from effectively inheriting their values from the derived topic. This fix includes a simple conditional jQuery script which removed any jQuery Validator `rules()` as well as any HTML5 `required` attributes from `input`, `select`, and `textarea` fields. Other validators and validation attributes are left intact. The `Key` (_Folder Name_) field will also retain its `required` attribute, since the `Key` attribute should always be defined. (Technically, we could inherit this value as well, but that's not currently implemented. As is, however, when a derived topic is set via the OnTopic Editor, the `Key` field will default to the derived topic's `Key` if a value for it hasn't already been set.)
2 parents 1ba3931 + 644e8be commit 5044e46

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

  • OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor

OnTopic.Editor.AspNetCore/Areas/Editor/Views/Editor/Edit.cshtml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@
108108
}
109109
});
110110
111+
@if (Model.Topic.DerivedTopic != null) {
112+
<text>
113+
/**
114+
* Disable required fields if derived topic, as missing values will be inherited
115+
*/
116+
$('section input, section textarea, section select')
117+
.not("section.Key input")
118+
.removeAttr('required')
119+
.rules('remove', 'required');
120+
</text>
121+
}
122+
111123
});
112124
113125
</script>

0 commit comments

Comments
 (0)