[TYPO3-core] RFC: #9562: Feature: onChange has no effect
Dan Osipov
dosipov at phillyburbs.com
Tue Nov 11 21:35:54 CET 2008
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 ;)
--
Dan Osipov
Calkins Media
http://danosipov.com/blog/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 9562.patch
Type: text/x-diff
Size: 6338 bytes
Desc: not available
Url : http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20081111/c3a11cb6/attachment-0001.patch
More information about the TYPO3-team-core
mailing list