Project

General

Profile

Feature #88925

Updated by Jonas Schwabe over 4 years ago

The additionalElementPropertyPaths property is currently only available for TextEditor https://docs.typo3.org/c/typo3/cms-form/master/en-us/I/Config/proto/formElements/formEditor/inspectorEditors/TextEditor.html#additionalelementpropertypaths 

 We had a use case today where we wanted to implement a validator that can be configured using checkboxes. To make sure we were able to have frontend validation we wanted to be able to set element properties as well (to pass those values to the frontend). 

 Implementing this feature is actually pretty simple so we created out own Inspector element for that which could probably go into ext:form directly: 

 <pre><code class="javascript"> 
        function renderPropagatingCheckboxEditor(editorConfiguration, editorHtml, collectionElementIdentifier, collectionName) { 
           // Code from original renderCheckboxEditor 

           $('input[type="checkbox"]', $(editorHtml)).on('change', function() { 
             if ( 
               !getUtility().isUndefinedOrNull(editorConfiguration['additionalElementPropertyPaths']) 
               && 'array' === $.type(editorConfiguration['additionalElementPropertyPaths']) 
             ) { 
               for (var i = 0, len = editorConfiguration['additionalElementPropertyPaths'].length; i < len; ++i) { 
                 if ( 
                   !!editorConfiguration['doNotSetIfPropertyValueIsEmpty'] 
                   && !($(this).is(":checked")) 
                 ) { 
                   getCurrentlySelectedFormElement().unset(editorConfiguration['additionalElementPropertyPaths'][i]); 
                 } else { 
                   getCurrentlySelectedFormElement().set(editorConfiguration['additionalElementPropertyPaths'][i], ($(this).is(":checked"))); true); 
                 } 
               } 
             } 
           }); 
         }; 
 </code></pre> 

Back