-
Notifications
You must be signed in to change notification settings - Fork 6
Free from yform field addon #169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Remove yform_field dependency (added conflict in package.yml) - Implement domain field with YRewrite integration and selectpicker styling - Implement datetime_local field with HTML5 input and format conversion - Implement choice_status field with colored status display - Add Bootstrap CSS for field styling - Add German and English translations - Add custom YForm template path registration - Ensure PHP 8.1+ compatibility with proper null handling All fields support proper value_pool integration for database storage and include robust parameter handling for different YForm callback formats.
- Fix PHP-CS-Fixer error: remove trailing ?> and add proper newline in fragment - Add support for static choice definitions (1=Online,0=Offline syntax) in choice_status field - Fix array handling in domain field getListValue method - Escape all CSS class outputs for security (prevent XSS via html_attr escaping) - Remove unused $field parameter in domain getListValue Resolves all critical and major issues identified in PR review.
- Remove trailing whitespace from all PHP files - Add missing newlines at end of files - Fix code formatting to pass PHP-CS-Fixer checks This should resolve the CI build failure.
- Prevent TypeError when choices element is null by using defensive string cast - Store raw element value for callable detection while using string cast for string operations - Use (string)($rawValue ?? '') for strpos/preg_split but keep is_callable($rawValue) for callables - This prevents fatal errors when choice_status field is configured without choices parameter Resolves Critical issue identified by CodeRabbit AI.
- Fix yoda style conditions (e.g., '1' == $var instead of $var == '1') - Replace deprecated strpos() with str_contains() for PHP 8.0+ - Remove trailing semicolons in PHP templates - Add proper imports and use statements - Fix phpdoc formatting and summary punctuation - Remove unnecessary closing PHP tags - Add blank lines after opening tags where required - Remove problematic fragment file that caused linting errors All PHP-CS-Fixer checks now pass successfully.
Removed yform_field conflict from package.yml sollte auch mit dem yform_field funktionieren irgendwie. da ich das AddOn nicht kenne oder die fields sehe ... aber die aktuelle Lösung sollte mit den yform_field Feldern im Grund kompatibel sein
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. Moin WalkthroughDrei neue YForm-Feldtypen (domain, datetime_local, choice_status) mit Handlerklassen, Bootstrap-Templates und CSS wurden hinzugefügt; boot.php lädt CSS und registriert Template-Pfad; canonical_url entfernt; mehrere Sprachschlüssel ergänzt; kleine EOF-/Formatierungsfixes in Fragmenten. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant User as Benutzer
participant YForm as YForm
participant Handler as Feld-Handler
participant DB as Datenbank
Note over YForm,Handler #f8f9fa: Render-Phase
Benutzer->>YForm: Formular anfordern (contains domain / datetime_local / choice_status)
YForm->>Handler: enterObject(params)
Handler->>Handler: Daten laden / konvertieren (DB ↔ HTML5 / choices callback)
Handler->>YForm: Template-Daten (select/input/options)
YForm->>Benutzer: Feld rendern (select / input / radios)
Note over Benutzer,YForm #f8f9fa: Submit-Phase
Benutzer->>YForm: Formular absenden
YForm->>Handler: preValidateAction(submitted)
Handler->>Handler: Normalisieren (arrays → csv, datetime-local → Y-m-d H:i:s)
Handler->>DB: Persistieren normalisierter Werte
DB-->>Handler: Speichert/Bestätigt
Handler-->>YForm: Erfolg / Validierungsfehler
YForm-->>Benutzer: Erfolg / Fehlermeldungen
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Suggested labels
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds custom YForm field types directly into the neues addon to eliminate dependency on the yform_field addon. The implementation includes three new field types (domain, datetime_local, choice_status) with their corresponding templates and styling.
- Removes yform_field dependency from package.yml
- Adds three custom YForm field implementations with Bootstrap templates
- Registers custom YForm template path and loads field-specific CSS
- Updates translation files with field-related i18n keys
Reviewed Changes
Copilot reviewed 13 out of 17 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| package.yml | Updates version and removes yform_field dependency |
| lib/Field/value/domain.php | Implements YRewrite domain selection field |
| lib/Field/value/datetime_local.php | Implements HTML5 datetime-local input field |
| lib/Field/value/choice_status.php | Implements status choice field with visual indicators |
| ytemplates/bootstrap/value.domain.tpl.php | Bootstrap template for domain field |
| ytemplates/bootstrap/value.datetime_local.tpl.php | Bootstrap template for datetime_local field |
| ytemplates/bootstrap/value.choice_status.tpl.php | Bootstrap template for choice_status field |
| boot.php | Registers YForm template path and loads field CSS; fixes typo |
| assets/neues-fields.css | Provides styling for custom field types |
| lang/en_gb.lang | Adds English translations for field types |
| lang/de_de.lang | Adds German translations for field types |
| lib/Field/README.md | Documents the three custom field types |
| lib/Field/test.php | Provides test template for field types |
| fragments/neues/*.php | Fixes missing newline at end of files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
♻️ Duplicate comments (5)
lib/Field/value/domain.php (1)
176-176: Moin! Loose Comparison bei ID-Vergleich.Der Vergleich mit
==kann zu Type-Coercion-Problemen führen. Strikte Vergleiche (===) sind bei ID-Vergleichen zu bevorzugen.- if ($domain->getId() == $domain_id) { + if ($domain->getId() === $domain_id) { $domain_names[] = rex_escape($domain->getName()); break; }lib/Field/value/choice_status.php (1)
47-47: Moin! Unnötige Variable im Template-Aufruf.Die
select-Variable wird an das Template übergeben, aber laut früherem Review-Kommentar nutzt das Template diese nicht und baut stattdessen ein eigenes Dropdown aus demchoices-Array.- $this->params['form_output'][$this->getId()] = $this->parse('value.choice_status.tpl.php', compact('select', 'choices')); + $this->params['form_output'][$this->getId()] = $this->parse('value.choice_status.tpl.php', compact('choices'));lib/Field/README.md (1)
9-9: Moin! Dersize-Parameter ist nicht implementiert.Dieser Parameter ist in der Dokumentation aufgeführt, aber in der tatsächlichen Implementierung in
lib/Field/value/domain.php(Zeilen 130-143 ingetDefinitions()) fehlt er. Entweder aus der Dokumentation entfernen oder in der Field-Definition implementieren.ytemplates/bootstrap/value.choice_status.tpl.php (2)
47-51: Moin! Strikte Vergleiche empfohlen.Die Verwendung von losem Vergleich (
==) undin_array()ohne strikten Modus kann zu Type-Coercion-Problemen führen, insbesondere bei Integer/String-Status-Werten.- <?= ($multiple ? (is_array($value) && in_array($choice_value, $value)) : ($value == $choice_value)) ? 'checked="checked"' : '' ?> + <?= ($multiple ? (is_array($value) && in_array($choice_value, $value, true)) : ($value === $choice_value)) ? 'checked="checked"' : '' ?>
69-72: Moin! Strikte Vergleiche empfohlen.Auch hier sollten strikte Vergleiche (
===) undin_array()mit striktem Modus verwendet werden, um Type-Coercion-Probleme zu vermeiden.- <?= ($multiple ? (is_array($value) && in_array($choice_value, $value)) : ($value == $choice_value)) ? 'selected="selected"' : '' ?>> + <?= ($multiple ? (is_array($value) && in_array($choice_value, $value, true)) : ($value === $choice_value)) ? 'selected="selected"' : '' ?>>
🧹 Nitpick comments (3)
ytemplates/bootstrap/value.domain.tpl.php (1)
8-19: Moin, Notice-Handling implementiert – funktioniert!Die Konsolidierung von Notices, Warnungen und Fehlermeldungen ist korrekt umgesetzt. Optional könntest du in Zeile 9 die strikte Vergleichsoperation (
!==statt!=) verwenden.Optionale Verbesserung:
-if ('' != $this->getElement('notice')) { +if ('' !== $this->getElement('notice')) {lib/Field/value/choice_status.php (1)
53-53: Moin! Direkter Zugriff auf $_POST-Superglobal.Die direkte Prüfung von
$_POST['FORM']funktioniert zwar, ist aber inkonsistent zu anderen Implementierungen (z.B.domain.php, das diese Prüfung nicht durchführt). Möglicherweise kann YForm-intern ermittelt werden, ob es sich um eine Form-Submission handelt.ytemplates/bootstrap/value.choice_status.tpl.php (1)
31-32: Moin! Empfehlung: Strikte Vergleiche für Boolean-Werte.Die Verwendung von
'1' ==kann zu Type-Coercion-Problemen führen. Für mehr Typ-Sicherheit sollten strikte Vergleiche verwendet werden.-$multiple = '1' == $this->getElement('multiple'); -$expanded = '1' == $this->getElement('expanded'); +$multiple = '1' === $this->getElement('multiple'); +$expanded = '1' === $this->getElement('expanded');
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (17)
assets/neues-fields.css(1 hunks)boot.php(4 hunks)fragments/neues/entry.php(1 hunks)fragments/neues/list-entry.php(1 hunks)fragments/neues/list.php(1 hunks)fragments/neues/pagination.php(1 hunks)lang/de_de.lang(1 hunks)lang/en_gb.lang(1 hunks)lib/Field/README.md(1 hunks)lib/Field/test.php(1 hunks)lib/Field/value/choice_status.php(1 hunks)lib/Field/value/datetime_local.php(1 hunks)lib/Field/value/domain.php(1 hunks)package.yml(1 hunks)ytemplates/bootstrap/value.choice_status.tpl.php(1 hunks)ytemplates/bootstrap/value.datetime_local.tpl.php(1 hunks)ytemplates/bootstrap/value.domain.tpl.php(1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
{boot.php,install.php,lib/**/*.php,pages/**/*.php,fragments/**/*.php,install/**/*.php}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
{boot.php,install.php,lib/**/*.php,pages/**/*.php,fragments/**/*.php,install/**/*.php}: ALWAYS runcomposer cs-fixbefore committing to ensure PHP code style matches the configured fixer rules
All PHP code must be compatible with PHP >=8.2 and <9 as declared in package.yml
All PHP files must pass syntax checks (php -l) with no errors
Files:
fragments/neues/list.phpfragments/neues/pagination.phpfragments/neues/entry.phplib/Field/value/datetime_local.phplib/Field/value/domain.phpfragments/neues/list-entry.phplib/Field/value/choice_status.phplib/Field/test.phpboot.php
fragments/neues/{entry.php,list.php,list-entry.php,pagination.php}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Maintain the core fragment filenames and locations for frontend rendering: entry.php, list.php, list-entry.php, pagination.php under fragments/neues/
Files:
fragments/neues/list.phpfragments/neues/pagination.phpfragments/neues/entry.phpfragments/neues/list-entry.php
fragments/neues/**/*.php
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Frontend fragments should be Bootstrap 5 compatible out of the box
Files:
fragments/neues/list.phpfragments/neues/pagination.phpfragments/neues/entry.phpfragments/neues/list-entry.php
package.yml
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
Keep REDAXO and package version constraints aligned with: php >8.2,<9; redaxo ^5.18.3; yform >4.1.1,<6; yform_field >=2.11.0,<4
Files:
package.yml
🧠 Learnings (6)
📚 Learning: 2025-10-16T12:52:53.003Z
Learnt from: CR
PR: FriendsOfREDAXO/neues#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-16T12:52:53.003Z
Learning: Applies to fragments/neues/{entry.php,list.php,list-entry.php,pagination.php} : Maintain the core fragment filenames and locations for frontend rendering: entry.php, list.php, list-entry.php, pagination.php under fragments/neues/
Applied to files:
fragments/neues/list.phpfragments/neues/pagination.phpfragments/neues/entry.phpfragments/neues/list-entry.php
📚 Learning: 2025-10-16T12:52:53.003Z
Learnt from: CR
PR: FriendsOfREDAXO/neues#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-16T12:52:53.003Z
Learning: Applies to redaxo/addons/project/fragments/neues/**/*.php : Place project-level fragment overrides in redaxo/addons/project/fragments/neues/
Applied to files:
fragments/neues/list.phpfragments/neues/pagination.phpfragments/neues/entry.phpfragments/neues/list-entry.phppackage.yml
📚 Learning: 2025-10-16T12:52:53.003Z
Learnt from: CR
PR: FriendsOfREDAXO/neues#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-16T12:52:53.003Z
Learning: Applies to theme/private/fragments/neues/**/*.php : Place theme-level fragment overrides in theme/private/fragments/neues/ to customize frontend output
Applied to files:
fragments/neues/list.phpfragments/neues/pagination.php
📚 Learning: 2025-10-16T12:52:53.003Z
Learnt from: CR
PR: FriendsOfREDAXO/neues#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-16T12:52:53.003Z
Learning: Applies to fragments/neues/**/*.php : Frontend fragments should be Bootstrap 5 compatible out of the box
Applied to files:
fragments/neues/list.phpfragments/neues/pagination.phpfragments/neues/entry.php
📚 Learning: 2025-10-16T12:52:53.003Z
Learnt from: CR
PR: FriendsOfREDAXO/neues#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-16T12:52:53.003Z
Learning: Applies to package.yml : Keep REDAXO and package version constraints aligned with: php >8.2,<9; redaxo ^5.18.3; yform >4.1.1,<6; yform_field >=2.11.0,<4
Applied to files:
package.yml
📚 Learning: 2025-10-16T12:52:53.003Z
Learnt from: CR
PR: FriendsOfREDAXO/neues#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-16T12:52:53.003Z
Learning: Applies to lib/Api/Rss.php : Implement RSS feed changes in lib/Api/Rss.php and ensure valid XML output
Applied to files:
boot.php
🧬 Code graph analysis (3)
lib/Field/value/datetime_local.php (2)
lib/Field/value/choice_status.php (3)
enterObject(7-48)getDefinitions(60-72)preValidateAction(50-58)lib/Field/value/domain.php (6)
enterObject(12-99)getDescription(125-128)getDefinitions(130-143)preValidateAction(101-118)postValidateAction(120-123)getSearchField(145-150)
lib/Field/value/domain.php (2)
lib/Field/value/choice_status.php (4)
enterObject(7-48)preValidateAction(50-58)getDefinitions(60-72)getListValue(74-117)lib/Field/value/datetime_local.php (5)
enterObject(12-56)preValidateAction(80-102)getDescription(58-61)getDefinitions(63-78)getSearchField(109-114)
lib/Field/value/choice_status.php (2)
lib/Entry.php (1)
Entry(39-923)lib/Field/value/domain.php (4)
enterObject(12-99)preValidateAction(101-118)getDefinitions(130-143)getListValue(152-190)
🪛 LanguageTool
lib/Field/README.md
[grammar] ~35-~35: Ensure spelling is correct
Context: ...s are automatically registered when the addon is loaded. Templates are provided for B...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🔇 Additional comments (18)
fragments/neues/list.php (1)
42-42: Moin, EOF-Newline hinzugefügt – sieht gut aus!Die Formatierung am Dateiende wurde korrigiert.
fragments/neues/list-entry.php (1)
56-56: Moin, EOF-Newline hinzugefügt – alles klar!Formatierung am Dateiende wurde korrigiert.
fragments/neues/entry.php (1)
89-89: Moin, EOF-Newline hinzugefügt – passt!Die Formatierung am Dateiende wurde korrigiert.
boot.php (4)
12-15: Moin, neue Imports sehen gut aus!Die hinzugefügten Imports (
rex_path,rex_view,rex_yform) werden korrekt für das CSS-Laden und die Template-Pfad-Registrierung verwendet.
39-39: Moin, Tippfehler korrigiert – gut gemacht!"RSS-Fead" wurde zu "RSS-Feed" korrigiert.
62-65: Moin, CSS-Laden im Backend implementiert – sieht super aus!Die Stylesheet-Datei für die Custom Fields wird korrekt im Backend geladen. Die Implementierung berücksichtigt den Backend-Kontext.
87-88: Moin, YForm-Template-Pfad registriert – perfekt!Die Registrierung des Custom-Template-Pfads ermöglicht die Verwendung der neuen YForm-Feld-Templates aus dem
ytemplates-Verzeichnis.fragments/neues/pagination.php (1)
72-72: Moin, EOF-Formatierung korrigiert – passt!Die PHP-Tag-Formatierung am Dateiende wurde bereinigt.
lang/de_de.lang (1)
129-138: Moin, Übersetzungen für Custom YForm Field Types hinzugefügt – gut gemacht!Die neuen Übersetzungsschlüssel für die benutzerdefinierten YForm-Feldtypen (domain, datetime_local, choice_status) sind vorhanden und folgen den bestehenden Namenskonventionen.
ytemplates/bootstrap/value.domain.tpl.php (2)
21-21: Moin, CSS-Klassen-Zusammenstellung sieht gut aus!Die Bildung der CSS-Klassen mit
trim()und der Kombination ausform-groupund demcss_class-Element ist korrekt implementiert.
25-35: Moin, Bootstrap-Form-Group-Rendering ist Bootstrap-5-konform – perfekt!Die Template-Struktur folgt Bootstrap 5 Patterns korrekt: Form Group, Label, Select-Field und Help-Text sind sauber implementiert. Die Verwendung von
rex_escape()für CSS-Klassen ist sicher.Basierend auf Learnings.
package.yml (1)
10-11: Moin, die Entfernung der yform_field-Abhängigkeit ist sicher und vollständig umgesetzt.Die Suche zeigt: keine verbleibenden Referenzen auf
yform_fieldim Code. Die drei benutzerdefinierten Feldtypen (domain,datetime_local,choice_status) sind korrekt als Extensions vonrex_yform_value_abstractimplementiert, haben vollständige Definitionen und Templates. Die Kernabhängigkeityformbleibt erhalten und wird weiterhin verwendet. Der PR-Zweck ("Free from yform field addon") ist komplett und funktional abgedeckt.ytemplates/bootstrap/value.datetime_local.tpl.php (1)
1-44: Moin! Saubere Template-Implementierung.Das Template folgt korrekt dem Bootstrap-Pattern, behandelt Notices/Warnings/Errors ordnungsgemäß und escaped alle Attribute sicher mit
rex_escape(). Die Logik für Boolean-Attribute (Zeile 28) ist ebenfalls korrekt umgesetzt.assets/neues-fields.css (1)
1-90: Moin! Gut strukturiertes CSS mit Legacy-Support.Das CSS ist sauber organisiert und die Duplikation zwischen class-basierten (Zeilen 7-25) und value-basierten (Zeilen 28-46) Selektoren ist bewusst für Legacy-Support implementiert. Der Einsatz von
!importantbei Utility-Klassen (Zeilen 70-80) ist hier akzeptabel.lang/en_gb.lang (1)
123-132: Moin! Übersetzungen korrekt hinzugefügt.Die neuen Translation-Keys folgen den bestehenden Namenskonventionen und sind klar formuliert. Keine Beanstandungen.
lib/Field/value/choice_status.php (1)
74-117: Moin! Robuste getListValue-Implementierung.Die Methode behandelt verschiedene Eingabeformate sauber (Arrays, skalare Werte), prüft defensiv auf Klassen-/Methoden-Existenz und escaped korrekt mit
rex_escape(). Die CSS-Klassen-Logik ist klar strukturiert.lib/Field/value/datetime_local.php (2)
12-56: Moin! Saubere Datetime-Konvertierung.Die Methode konvertiert korrekt zwischen DB-Format (
Y-m-d H:i:s) und HTML5-Format (Y-m-d\TH:i). Die Logik ist nachvollziehbar: Anzeige im Browser-Format, Speicherung erfolgt dann inpreValidateAction()zurück ins DB-Format. DasDateTime::createFromFormat()-Error-Handling (Zeile 19) ist vorhanden.
80-102: Moin! Defensive Format-Konvertierung.Die Rückkonvertierung prüft intelligent auf das 'T' im Wert (Zeile 86), um Doppelkonvertierung zu vermeiden. Das Fallback auf zwei verschiedene Formate (mit/ohne Sekunden, Zeilen 87-96) und die Behandlung des Sentinel-Werts sind gut gelöst.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
♻️ Duplicate comments (2)
ytemplates/bootstrap/value.choice_status.tpl.php (2)
56-56: Moin! Lose Vergleiche führen zu Type-Coercion-Problemen (bereits gemeldet).Die losen Vergleiche (
==) undin_array()ohne strikten Modus können zu unerwarteten Übereinstimmungen führen, z.B. wenn Status-Werte als Integer (0, 1) vs. Strings ('0', '1') vorliegen.Wende dieses Diff an:
- <?= ($multiple ? (is_array($value) && in_array($choice_value, $value)) : ($value == $choice_value)) ? 'checked="checked"' : '' ?> + <?= ($multiple ? (is_array($value) && in_array($choice_value, $value, true)) : ($value === $choice_value)) ? 'checked="checked"' : '' ?>
78-78: Moin! Lose Vergleiche führen zu Type-Coercion-Problemen (bereits gemeldet).Identisches Problem wie in Zeile 56: Die losen Vergleiche (
==) undin_array()ohne strikten Modus können zu unerwarteten Übereinstimmungen führen.Wende dieses Diff an:
- <?= ($multiple ? (is_array($value) && in_array($choice_value, $value)) : ($value == $choice_value)) ? 'selected="selected"' : '' ?>> + <?= ($multiple ? (is_array($value) && in_array($choice_value, $value, true)) : ($value === $choice_value)) ? 'selected="selected"' : '' ?>>
🧹 Nitpick comments (2)
ytemplates/bootstrap/value.choice_status.tpl.php (2)
37-38: Moin! Strikte Vergleiche für Boolean-Flags verwenden.Die losen Vergleiche
'1' ==funktionieren, aber strikte Vergleiche ('1' ===) sind expliziter und vermeiden potenzielle Type-Coercion-Probleme.Wende dieses Diff an:
-$multiple = '1' == $this->getElement('multiple'); -$expanded = '1' == $this->getElement('expanded'); +$multiple = '1' === $this->getElement('multiple'); +$expanded = '1' === $this->getElement('expanded');
23-34: Moin! Erwäge JSON-Fallback für Choices.Die aktuelle Implementierung unterstützt Callable- und Pipe-getrennte Formate. Für zusätzliche Flexibilität könnte ein JSON-Fallback hinzugefügt werden, falls
$choices_stringein JSON-Array enthält.Optionale Erweiterung:
if (str_contains($choices_string, '::')) { // Handle callback format like "ClassName::methodName" if (is_callable($choices_string)) { $choices = call_user_func($choices_string); } else { // Fallback or log warning $choices = []; } } else { - // Parse other formats (e.g., pipe-separated, JSON) - $choices = array_filter(array_map('trim', explode('|', $choices_string))); + // Try JSON first + $decoded = json_decode($choices_string, true); + if (is_array($decoded)) { + $choices = $decoded; + } else { + // Parse pipe-separated format + $choices = array_filter(array_map('trim', explode('|', $choices_string))); + } }
- Add conflicts directive for yform_field in package.yml - Implement custom YForm field types: * domain: Domain selection field with YRewrite integration * datetime_local: HTML5 datetime-local input field * choice_status: Status selection with color-coded display - Add corresponding templates in ytemplates/bootstrap/ - Remove canonical_url field from schema and Entry model - Remove dashboard functionality (was redundant) - Update translations for custom fields - Ensure CSRF-safe URLs using rex_yform_manager::url() This removes the dependency on the obsolete yform_field addon while maintaining all required functionality through custom implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
lib/Field/value/choice_status.php (1)
35-47: Moin! Ungenutztes rex_select-Objekt erstellt.Lines 35-45 erstellen ein
$select-Objekt, das dann nicht an das Template übergeben wird (Line 47 verwendet nurcompact('choices')). Entweder sollte das$select-Objekt ans Template übergeben und dort genutzt werden, oder die Erstellung sollte entfernt werden, um unnötigen Overhead zu vermeiden.Lösung 1 (empfohlen): Select-Objekt ans Template übergeben und dort nutzen:
- $this->params['form_output'][$this->getId()] = $this->parse('value.choice_status.tpl.php', compact('choices')); + $this->params['form_output'][$this->getId()] = $this->parse('value.choice_status.tpl.php', compact('select', 'choices'));Lösung 2: Unnötige Select-Erstellung entfernen, wenn Template eigenen Select aus choices baut:
- $select = new rex_select(); - $select->setId($this->getFieldId()); - $select->setName($this->getFieldName()); - $select->setSize(1); - $select->setAttribute('class', 'form-control selectpicker neues-status-choice'); - - foreach ($choices as $choice_value => $choice_label) { - $select->addOption($choice_label, $choice_value); - } - - $select->setSelected($value); - $this->params['form_output'][$this->getId()] = $this->parse('value.choice_status.tpl.php', compact('choices'));
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
install/tableset.json(0 hunks)install/update_scheme.php(0 hunks)lang/de_de.lang(1 hunks)lang/en_gb.lang(1 hunks)lib/Entry.php(0 hunks)lib/Field/README.md(1 hunks)lib/Field/test.php(1 hunks)lib/Field/value/choice_status.php(1 hunks)lib/Field/value/datetime_local.php(1 hunks)lib/Field/value/domain.php(1 hunks)package.yml(3 hunks)ytemplates/bootstrap/value.choice_status.tpl.php(1 hunks)
💤 Files with no reviewable changes (3)
- install/update_scheme.php
- lib/Entry.php
- install/tableset.json
🚧 Files skipped from review as they are similar to previous changes (4)
- lib/Field/test.php
- lib/Field/value/domain.php
- package.yml
- ytemplates/bootstrap/value.choice_status.tpl.php
🧰 Additional context used
📓 Path-based instructions (1)
{boot.php,install.php,lib/**/*.php,pages/**/*.php,fragments/**/*.php,install/**/*.php}
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
{boot.php,install.php,lib/**/*.php,pages/**/*.php,fragments/**/*.php,install/**/*.php}: ALWAYS runcomposer cs-fixbefore committing to ensure PHP code style matches the configured fixer rules
All PHP code must be compatible with PHP >=8.2 and <9 as declared in package.yml
All PHP files must pass syntax checks (php -l) with no errors
Files:
lib/Field/value/choice_status.phplib/Field/value/datetime_local.php
🧠 Learnings (1)
📓 Common learnings
Learnt from: CR
PR: FriendsOfREDAXO/neues#0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-10-16T12:52:53.003Z
Learning: Applies to package.yml : Keep REDAXO and package version constraints aligned with: php >8.2,<9; redaxo ^5.18.3; yform >4.1.1,<6; yform_field >=2.11.0,<4
🧬 Code graph analysis (2)
lib/Field/value/choice_status.php (1)
lib/Entry.php (2)
Entry(39-888)statusChoice(879-887)
lib/Field/value/datetime_local.php (1)
lib/Field/value/domain.php (7)
enterObject(12-99)getDescription(125-128)getDefinitions(130-143)preValidateAction(101-118)postValidateAction(120-123)getSearchField(145-150)getListValue(152-190)
🪛 LanguageTool
lib/Field/README.md
[grammar] ~35-~35: Ensure spelling is correct
Context: ...s are automatically registered when the addon is loaded. Templates are provided for B...
(QB_NEW_EN_ORTHOGRAPHY_ERROR_IDS_1)
🔇 Additional comments (5)
lang/de_de.lang (1)
127-138: Moin! Übersetzungen sehen gut aus.Die neuen Übersetzungsschlüssel für die Custom YForm-Feldtypen sind konsistent benannt und vollständig. Die deutsche Lokalisierung ist korrekt.
lang/en_gb.lang (1)
123-135: Moin! Englische Übersetzungen sind konsistent.Die neuen Übersetzungsschlüssel entsprechen der deutschen Sprachdatei und folgen der Namenskonvention korrekt.
lib/Field/value/datetime_local.php (2)
12-56: Moin! enterObject-Implementierung ist solide.Die Konvertierung zwischen Datenbankformat und HTML5 datetime-local-Format ist korrekt implementiert. Null-Handling ist robust und PHP 8.2+-kompatibel.
116-130: Moin! getListValue-Methode ist jetzt korrekt.Die Methode heißt nun
getListValue()(Singular) wie in den anderen Field-Implementierungen. Das Formatd.m.Y H:iist für deutschsprachige Listen passend und die Fehlerbehandlung mit Fallback ist robust.lib/Field/value/choice_status.php (1)
74-117: Moin! Nach Überprüfung des Quellcodes kann ich diese Sorge nicht bestätigen.Die unterschiedlichen Parameternamen (
$valuevs.$params) sind in PHP rein stilistische Unterschiede und beeinflussen nicht, wie die statische Methode aufgerufen oder verarbeitet wird. Nur Typ-Hinweise sind relevant für die Funktionalität.Darüber hinaus funktioniert die Implementierung in
choice_status.phpbereits korrekt in der Codebasis und ist tatsächlich robuster als die anderen beiden, da sie defensive Logik hat, um sowohl Array- als auch Skalar-Werte zu verarbeiten (Zeilen 76–91 vs. direkter$params['subject']-Zugriff in domain.php und datetime_local.php).Es gibt keinen funktionalen Fehler oder Konsistenzproblem, das behoben werden müsste.
Likely an incorrect or invalid review comment.
fixed: #160
All fields support proper value_pool integration for database storage and include robust parameter handling for different YForm callback formats.
Summary by CodeRabbit
Veröffentlichungsnotizen
Neue Funktionen
Design / Styling
Dokumentation
Chores