[TikiWiki-commits] [Git][tikiwiki/tiki][27.x] [BP][FIX] Trackers: Prevent client-side validation on mandatory auto-increment fields
"Sammy Ndabo \(@ndabosam084\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <693d6d76454c0_2a17f3681557@gitlab-sidekiq-low-urgency-cpu-bound-v2-64d4768b4d-w8kxg.mail> |
Sammy Ndabo pushed to branch 27.x at Tiki Wiki CMS Groupware / Tiki
Commits:
0c515109 by Sammy Ndabo at 2025-12-13T13:37:08+00:00
[BP][FIX] Trackers: Prevent client-side validation on mandatory auto-increment fields
---
* [BP][FIX] Trackers: Prevent client-side validation on mandatory auto-increment fields
---
* [BP][FIX] Trackers: Prevent client-side validation on mandatory auto-increment fields
---
* [FIX] Trackers: Prevent client-side validation on mandatory auto-increment fields
---
* [FIX] Trackers: Prevent client-side validation on mandatory auto-increment fields
See merge request tikiwiki/tiki!8568
(cherry picked from commit 4a5d09dc79c0502dca59b98581d394ab72edfdb3)
See merge request tikiwiki/tiki!8590
(cherry picked from commit 2ca1d05555cadbeb0a1839daf3826596a8217729)
See merge request tikiwiki/tiki!9228
(cherry picked from commit 80c2a08d1da9846e0e346129ad2c72c499757c1b)
See merge request tikiwiki/tiki!9229
- - - - -
3 changed files:
- lib/core/Tracker/Field/AbstractItemField.php
- lib/core/Tracker/Field/AutoIncrement.php
- lib/validatorslib.php
Changes:
=====================================
lib/core/Tracker/Field/AbstractItemField.php
=====================================
@@ -676,4 +676,16 @@ abstract class AbstractItemField implements ItemFieldInterface, IndexableInterfa
{
return '';
}
+ /**
+ * Determines if a field, when marked as mandatory, should be validated
+ * on the client-side (in browser JavaScript).
+ *
+ * @return bool True if client-side validation should apply, false otherwise.
+ */
+ public function isClientSideMandatory(): bool
+ {
+ // By default, all mandatory fields are validated on the client side.
+ // Specific field types can override this behavior.
+ return true;
+ }
}
=====================================
lib/core/Tracker/Field/AutoIncrement.php
=====================================
@@ -137,6 +137,18 @@ class Tracker_Field_AutoIncrement extends \Tracker\Field\AbstractItemField imple
];
}
+ /**
+ * Overrides the default client-side validation behavior.
+ * An auto-increment field's value is generated on the server, so it should
+ * never be considered mandatory by client-side JavaScript validation.
+ *
+ * @return bool Always returns false.
+ */
+ public function isClientSideMandatory(): bool
+ {
+ return false;
+ }
+
public function getTabularSchema()
{
$schema = new Tracker\Tabular\Schema($this->getTrackerDefinition());
=====================================
lib/validatorslib.php
=====================================
@@ -76,7 +76,7 @@ class Validators
$validationjs .= $prefix . $field_value['fieldId'] . ': { ';
}
}
- if ($isMandatory) {
+ if ($isMandatory && $handler->isClientSideMandatory()) {
if ($field_value['type'] == 'D') {
$validationjs .= 'required_in_group: [1, ".group_' . $prefix . $field_value['fieldId'] . '", "other"], ';
} elseif ($field_value['type'] == 'A') {
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/0c515109d63ca2e01dab47be6cb9ae6b60717923
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/0c515109d63ca2e01dab47be6cb9ae6b60717923
You're receiving this email because of your account on gitlab.com.
_______________________________________________
TikiWiki-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tikiwiki-cvs