Skip to content

fix: notice Attribut im MFormParameterHandler ergänzt - #394

Merged
skerbis merged 1 commit into
mainfrom
feature/notice-parameter-support
Mar 10, 2026
Merged

fix: notice Attribut im MFormParameterHandler ergänzt#394
skerbis merged 1 commit into
mainfrom
feature/notice-parameter-support

Conversation

@skerbis

@skerbis skerbis commented Mar 10, 2026

Copy link
Copy Markdown
Member

Problem

Das notice Attribut konnte nicht über den Parameter-Array übergeben werden (z.B. bei addMediaField, addTextField etc.), obwohl label und full bereits unterstützt wurden.

Lösung

notice-Case im MFormParameterHandler ergänzt – analog zu label und full.

Verwendung

$mform->addTextField('email', [
    'label' => 'E-Mail-Adresse',
    'notice' => 'An diese Adresse wird eine Bestätigungsmail gesendet'
]);

$mform->addMediaField(1, [
    'label' => 'Bild',
    'notice' => 'Mindestens 2800px Breite'
]);

Hinweis

Die restliche Implementation (MFormItem, MFormElement, MFormAttributeHandler, MFormParser, Fragment mform_default.php) war bereits vollständig vorhanden. Dieser Fix schließt die letzte fehlende Lücke.

Closes #389

Summary by CodeRabbit

Neue Funktionen

  • Formulare unterstützen nun die Verarbeitung und Speicherung von Benachrichtigungen durch einen dedizierten Parameter.

Copilot AI review requested due to automatic review settings March 10, 2026 22:24
@coderabbitai

coderabbitai Bot commented Mar 10, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3f5e0b06-59d2-496d-8c4b-599006a2b682

📥 Commits

Reviewing files that changed from the base of the PR and between fc2d183 and a7f93b6.

📒 Files selected for processing (1)
  • lib/MForm/Handler/MFormParameterHandler.php

Moin

Walkthrough

Die Änderung erweitert den MFormParameterHandler um Unterstützung für den Parameter 'notice'. Wenn der Parametername 'notice' lautet, wird die Setter-Methode setNotice() auf dem Item aufgerufen und die Verarbeitung abgebrochen, bevor auf die Standard-Parameterspeicherung zurückgegriffen wird.

Changes

Cohort / File(s) Summary
Notice-Parameter Behandlung
lib/MForm/Handler/MFormParameterHandler.php
Neue Switch-Case für Parameter 'notice', die $item->setNotice($value) aufruft und damit die Speicherung von Notice-Werten über den dedizierten Setter ermöglicht.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 Minuten

Possibly related PRs

Suggested reviewers

  • joachimdoerr
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Der PR adressiert nur einen Teil von Issue #389: Behandlung im MFormParameterHandler. Die Anforderungen für MFormItem, MFormElement, MFormParser und Fragment sind nicht im PR enthalten. Implementieren Sie auch die Property-Ergänzungen in MFormItem, MFormElement sowie die Anpassungen in MFormParser und dem Fragment mform_default.php gemäß Issue #389.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Der Titel beschreibt korrekt die Hauptänderung: Ergänzung des notice-Attributs im MFormParameterHandler.
Out of Scope Changes check ✅ Passed Alle Änderungen sind direkt auf die Ergänzung des notice-Parameters im Handler beschränkt und dem Umfang entsprechend.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/notice-parameter-support

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@skerbis
skerbis merged commit fe04d92 into main Mar 10, 2026
2 of 3 checks passed
@skerbis
skerbis deleted the feature/notice-parameter-support branch March 10, 2026 22:26

Copilot AI left a comment

Copy link
Copy Markdown

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 closes the remaining gap so the notice attribute can be passed via the parameter array (e.g. in addMediaField, addLinkField, etc.) by adding notice handling to MFormParameterHandler, consistent with existing handling for label and full.

Changes:

  • Add notice case to MFormParameterHandler::addParameter() to map to MFormItem::setNotice()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

$item->setFull(true);
break;
case 'notice':
$item->setNotice($value);

Copilot AI Mar 10, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MFormItem::setNotice() expects a string, but MFormParameterHandler::addParameter() forwards $value as mixed. If callers pass null/array/object in the parameter array, this will raise a TypeError. Consider normalizing here (e.g., treat null as '' and cast scalars to string, or validate and throw a clearer exception).

Suggested change
$item->setNotice($value);
if ($value === null) {
$normalizedNotice = '';
} elseif (is_scalar($value) || (is_object($value) && method_exists($value, '__toString'))) {
$normalizedNotice = (string) $value;
} else {
throw new \InvalidArgumentException(
'MFormParameterHandler::addParameter(): parameter "notice" must be stringable, ' . gettype($value) . ' given'
);
}
$item->setNotice($normalizedNotice);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unterstützung für notice Attribut in Formularfeldern

2 participants