[TYPO3-core] RFC: #9562: Feature: onChange has no effect

Dan Osipov dosipov at phillyburbs.com
Wed Nov 12 20:53:30 CET 2008


Attached is a crude extension testing this functionality. Feel free to 
rip it apart.

While making the extension I noticed a bug in my implementation - it 
requires at least one IRRE element to be present to work. I'll wait for 
your other comments before proceeding to fix it - I have a feeling there 
will be a few.

Dan Osipov
Calkins Media
http://danosipov.com/blog/

Dan Osipov wrote:
> Hello,
> 
> This is an SVN patch request
> 
> Type: Missing Feature
> Branches: Trunk
> BT Reference: http://bugs.typo3.org/view.php?id=9562
> 
> Problem:
> FlexForms have an onChange => reload directive, which reloads the form 
> if a field is changed. This is very useful. Regular forms also have 
> 'requestUpdate' => field which does the same thing. However, there are 
> two problems: 1) regular TCEForms ignore the onChange directive, and 2) 
> IRRE ignores these completely.
> 
> Solution:
> Attached patch fixes the first problem by adding a condition to the if 
> statement, which reloads the form if a field with onChange = reload is 
> changed. It also adds a feature to IRRE, so that if a field is changed, 
> the record is reloaded. This is done using AJAX, so the entire page is 
> not reloaded - just the record currently being edited. Also, the change 
> is not saved in the DB - it's changed on the fly, and may impact how 
> other fields rendered, but its not saved until the form is saved.
> 
> How to test:
> Here are some sample TCA configurations I have used during development 
> of this patch:
> 
> IRRE field:
>     "tx_pbwltottnews_widget_id" => Array (       
>         "label" => "Widgets",
>         "config" => Array (
>             "type" => "inline",
>                     "foreign_table" => "tx_pbwidgetlibrary_mm",
>                     "foreign_table_field" => "ext_table",
>                     "foreign_field" => "record_id",
>                     "foreign_sortby" => "sorting",
>                     "foreign_label" => "widget_id",
>         )
>     ),
> 
> MM table:
> $TCA["tx_pbwidgetlibrary_mm"] = array (
>     "ctrl" => array (
>         'title'     => 
> 'LLL:EXT:pb_widget_library/locallang_db.xml:tx_pbwidgetlibrary_mm',
>         'label'     => 'widget_id',
>         'default_sortby' => "ORDER BY sorting",
>         'delete' => 'deleted',
>     'requestUpdate' => 'type',      // This is what tells the field to 
> reload!
>         'enablecolumns' => array (
>             'disabled' => 'hidden',
>         ),
>         'dynamicConfigFile' => t3lib_extMgm::extPath($_EXTKEY).'tca.php',
>         'iconfile'          => 
> t3lib_extMgm::extRelPath($_EXTKEY).'icon_tx_pbwidgetlibrary_mm.gif',
>     ),
>     "feInterface" => array (
>         "fe_admin_fieldList" => "widget_id, type, record_id",
>     )
> );
> 
> MM table TCA:
> $TCA["tx_pbwidgetlibrary_mm"] = array (
>     "ctrl" => $TCA["tx_pbwidgetlibrary_mm"]["ctrl"],
>     "interface" => array (
>         "showRecordFieldList" => "hidden"
>     ),
>     "feInterface" => $TCA["tx_pbwidgetlibrary_mm"]["feInterface"],
>     "columns" => array (
>         "widget_id" => Array (
>             "label" => "Widget",
>             "config" => Array (
>                 "type" => "select",
>                 "foreign_table" => "tx_pbwidgetlibrary_widget",
>                 "foreign_table_where" => " AND 
> tx_pbwidgetlibrary_widget.type='###REC_FIELD_type###'",
>                 "maxitems" => 1,
>             )
>         ),
>         "type" => Array (
>             "exclude" => 1,
>             "label" => 
> "LLL:EXT:pb_widget_library/locallang_db.xml:tx_pbwidgetlibrary_widget.type", 
> 
>             "config" => Array(
>                 "type" => "select",
>                 "itemsProcFunc" => 
> "tx_pbwidgetlibrary_addFieldsToFlexForm->listWidgets",
>                 "onChange" => "reload",   // This is an alternative way 
> to get the form to reload.
>             )
>         ),
>         "record_id" => Array (       
>             "exclude" => 1,       
>             "label" => "Record",       
>             "config" => Array (
>                 "type" => "select",
>                 "foreign_table" => "tt_news",
>             )
>         ),
>         "sorting" => Array (
>             "config" => Array (
>                  "type" => "passthrough",
>              )
>         ),
>     ),
>     "types" => Array (
>         "0" => Array("showitem" => "hidden;;1, title;;;;2-2-2, type, 
> widget_id;;;;3-3-3, record_id, sorting")
>     ),
>     "palettes" => Array (
>         "1" => Array("showitem" => "")
>     )
> );
> 
> Let me know if you have questions.
> FYI: This is my first patch to the core (and it wasn't an easy one), so 
> please, be nice ;)
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: T3X_test_9562-0_0_0-z-200811121450.t3x
Type: application/octet-stream
Size: 12753 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20081112/5d78dcb5/attachment-0001.obj 


More information about the TYPO3-team-core mailing list