[TikiWiki-commits] [Git][tikiwiki/tiki][29.x] [BP][FIX] Trackers: Prevent client-side validation on mandatory auto-increment fields
"MAGENE Sem Joel \(@Jomagene\) via TikiWiki-cvs" <[email protected]>
| Newsgroups | gmane.comp.cms.tiki.cvs |
|---|---|
| Message-ID | <68c98ab78a119_2cde954297e@gitlab-sidekiq-low-urgency-cpu-bound-v2-6849cbcf9c-7qjmh.mail> |
MAGENE Sem Joel pushed to branch 29.x at Tiki Wiki CMS Groupware / Tiki
Commits:
2ca1d055 by MAGENE Sem Joel at 2025-09-16T15:58:20+00:00
[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
- - - - -
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
=====================================
@@ -697,4 +697,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
=====================================
@@ -85,7 +85,7 @@ class Validators
} else {
$validationjs .= '"' . $field_name . '"' . ': { ';
}
- if ($isMandatory) {
+ if ($isMandatory && $handler->isClientSideMandatory()) {
if ($field_value['type'] == 'D') {
$validationjs .= 'required_in_group: [1, ".group_' . $field_name . '", "other"], ';
} elseif ($field_value['type'] == 'A') {
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2ca1d05555cadbeb0a1839daf3826596a8217729
--
View it on GitLab: https://gitlab.com/tikiwiki/tiki/-/commit/2ca1d05555cadbeb0a1839daf3826596a8217729
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