Skip to content

Conversation

Copy link

Copilot AI commented Oct 29, 2025

Users need to exclude fields from YORM-generated forms (e.g., hiding name/surname in user profile edits) without creating custom model classes and overriding getFields().

Changes

  • rex_yform_manager_dataset::getForm(array $excludeFields = []) - Added optional parameter to exclude fields by name
  • rex_yform_manager_collection::getForm(array $excludeFields = []) - Same exclusion capability for multi-edit forms
  • createForm() - Filters excluded fields during form construction using in_array() check

Usage

// Exclude name and surname from form
$dataset = rex_data_kontakte::get($id);
$yform = $dataset->getForm(['name', 'surname']);

// Still supports hidden fields for excluded data
$yform->setValueField('hidden', ['kreis', $kreis, 'REQUEST']);
echo $dataset->executeForm($yform);

Backward compatible - existing calls without parameters continue to work unchanged.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/c3fe76976081ab871aa654e872da588077e19679
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/composer/pcre/zipball/b2bed4734f0cc156ee1fe9c0da2550420d99a21e
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/composer/semver/zipball/198166618906cb2de69b95d7d47e5fa8aa1b2b95
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/composer/xdebug-handler/zipball/6c1925561632e83d60a44492e0b344cf48ab85ef
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/kubawerlos/php-cs-fixer-custom-fixers/zipball/e03b07a58e08133c92c9e7a5ccc69e1457f8c98d
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/redaxo/php-cs-fixer-config/zipball/5ab76b209f34d09268b9e9c8ee4f3d6b650e9ff1
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/exporter/zipball/14c6ba52f95a36c3d27c835d65efc7123c446e8c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/object-reflector/zipball/b4f479ebdbf63ac605d183ece17d8d7fe49c15c7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/phpunit/zipball/9ecfec57835a5581bc888ea7e13b51eb55ab9dd3
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/539c6691e0623af6dc6f9c20384c120f963465a0
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/05d5692a7993ecccd56a03e40cd7e5b09b1d404e
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/type/zipball/75e2c2a32f5e0b3aef905b9ed0b179b953b3d7c7
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/sebastianbergmann/version/zipball/c6c1022351a901512170118436c764e473f6de8c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/console/zipball/13d3176cf8ad8ced24202844e9f95af11e2959fc
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/deprecation-contracts/zipball/63afe740e99a13ba87ec199bb07bbdee937a5b62
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/options-resolver/zipball/d28e7e2db8a73e9511df892d36445f61314bbebe
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/380872130d3a5dd3ace2f4010d95125fde5d5c70
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/3833d7255cc303546435cb650316bff708a1c75c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-php80/zipball/0cc9dd0f17f61d8131e7df6b84bd344899fe2608
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/polyfill-php81/zipball/4a4cfc2d253c21a5ad0e53071df248ed48c6ce5c
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/process/zipball/48bad913268c8cafabbf7034b39c8bb24fbc5ab8
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/service-contracts/zipball/f021b05a130d35510bd6b25fe9053c2a8a15d5d4
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/stopwatch/zipball/b67e94e06a05d9572c2fa354483b3e13e3cb1898
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)
  • https://api.github.com/repos/symfony/string/zipball/f96476035142921000338bad71e5247fbc138872
    • Triggering command: /usr/bin/php8.3 -n -c /tmp/ZfHDlQ /usr/bin/composer install --no-interaction (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Exclude für YORM</issue_title>
<issue_description>Mit YORM erstelle ich aktuell so ein Formular . Das ist soweit ok.
Allerdings fehlt die Möglichkeit bestimmte Felder zu exkluden.
Also z.B. Bei einem User-Profil, soll der Name und Vorname nicht mehr angezeigt oder bearbeitet werden können.
Oder man braucht das Formular noch mal aber mit weniger Details.

Hier wäre es gut $manager mitzuteilen dass er felder excluden soll, wenn werte gewünscht sind kann man ja dann immer noch sowas wie $yform->setValueField('hidden', array("kreis", $kreis, 'REQUEST')); setzen

<?php 
if (rex_ycom_auth::getUser() and rex_ycom_auth::getUser()->getValue('kreis'))
{    
$kreis = rex_ycom_auth::getUser()->getValue('kreis');
$button ='<a class="uk-float-right uk-button-primary uk-button" href="'.rex_getUrl(42).'">Zurück zur Übersicht</a><div class="clear"></div>'; 
echo $button;
$sliceID='S_REX_SLICE_ID';

$manager = Url\Url::resolveCurrent();
if($newsDataId = $manager->getDatasetId())
{
$dataset = rex_data_kontakte::get($newsDataId);
#dump($dataset);
 
$yform = $dataset->getForm();
$yform->setValueField('mediafile3', array('bild','Bild zur Person (max. 5MB)','5120','.jpg,.JPG,.PNG,.GIF','0','Das Bild entspricht nicht den Vorgaben','','57','',' Erlaubt sind Fotos im JPG-Format. Ideal sind Bilder im Hochformat, dennoch wünschenswert ist es ein wenig "Luft" um das Motiv zu haben, weil die Bilder automatisch zugeschnitten werden.'));
$yform->setValueField('hidden', array("kreis", $kreis, 'REQUEST'));
// Evtl. Hidden Fields setzen etc.
$yform->setObjectparams('form_action',rex_getUrl('', '', ['contact_edit' => $newsDataId]));
$yform->setObjectparams('form_showformafterupdate',0);

// für neuen Datensatz
#$yform->setObjectparams("main_where",'');
#$yform->setObjectparams("main_id",-1);
$yform->setObjectparams("form_name",$sliceID);
// Daten laden true für ja, false für nein
$yform->setObjectparams("getdata",true);
// Für neuen Datensatz
// $yform->setActionField("db", array("newskategorie",""));
$link ='<a class="uk-float-right uk-button-primary uk-button" href="'.rex_getUrl(42).'">Zurück zur Übersicht</a>'; 
$yform->setActionField('showtext', array('<h1 class="uk-animation-scale-up">Datensatz bearbeitet</h1>'.$link,'<span class="xform-msg saved">','</span>','1'));
 // print_r($yform);
echo $dataset->executeForm($yform);
}  else { echo 'Es wurde kein passender Datensatz gefunden.';}}
?>

  <link rel="stylesheet" type="text/css" media="all" href="/assets/addons/cke5/cke5.css?buster=1532942007" />
    <script type="text/javascript" src="/assets/addons/cke5/vendor/ckeditor5-classic/ckeditor.js?buster=1532942008"></script>
    <script type="text/javascript" src="/assets/addons/cke5/cke5translations.js?buster=1534176119"></script>
    <script type="text/javascript" src="/assets/addons/cke5/cke5profiles.js?buster=1534176119"></script>
  

<script>
/**
 * @author mail[at]doerr-softwaredevelopment[dot]com Joachim Doerr
 * @package redaxo5
 * @license MIT
 */

let ckeditors = {},
    ckareas = '.cke5-editor';

$( document ).ready(function() {
    if (typeof mblock_module === 'object') {
        mblock_module.registerCallback('reindex_end', function () {
            if ($(ckareas).length) {
                if (mblock_module.lastAction === 'add_item') {
                    cke5_destroy(mblock_module.affectedItem.find(ckareas));
                    cke5_init_all(mblock_module.affectedItem.find(ckareas));
                }
            }
        });
    }
});

$( document ).ready(function() {
    if ($(ckareas).length) {
        cke5_init_all($(ckareas));
    }
});

function cke5_init_all(elements) {
    elements.each(function () {
        cke5_init($(this));
    });
}


editingView.document.on( 'clipboardInput', ( evt, data ) => {
    if ( editor.isReadOnly ) {
        return;
    }

    const dataTransfer = data.dataTransfer;

    let content = plainTextToHtml( dataTransfer.getData( 'text/plain' ) );

    content = clipboardPlugin._htmlDataProcessor.toView( content );

    clipboardPlugin.fire( 'inputTransformation', { content, dataTransfer } );

    editingView.scrollToTheSelection();

    evt.stop();
} );



function cke5_init(element) {
    let unique_id = 'ck' + Math.random().toString(16).slice(2),
        options = {},
        sub_options = {},
        profile_set = 'light',
        min_height = element.attr('data-min-height'),
        max_height = element.attr('data-max-height'),
        lang = element.attr('data-lang');

    element.attr('id', unique_id);

    if (typeof profile_set === 'undefined' || !profile_set) { } else {
        if (profile_set in cke5profiles) {
            options = cke5profiles[profile_set];
        }
        if (profile_set in cke5suboptions) {
            sub_options = cke5suboptions[profile_set];
        }
    }
    if (typeof min_height === 'undefined' || !min_height) { } else {
        sub_options['min-height'] =...

</details>

- Fixes KLXM/yform#1

<!-- START COPILOT CODING AGENT TIPS -->
---

✨ Let Copilot coding agent [set things up for you](https://github.com/KLXM/yform/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot) — coding agent works faster and does higher quality work when set up for your repo.

- Add optional excludeFields parameter to getForm() in dataset and collection classes
- Filter out excluded fields when building forms
- Add comprehensive test for exclude functionality

Co-authored-by: skerbis <791247+skerbis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add functionality to exclude fields in YORM forms Add field exclusion parameter to YORM getForm() Oct 29, 2025
Copilot AI requested a review from skerbis October 29, 2025 14:35
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.

2 participants