Hi,
This is to do with custom filtering on a per field basis and for clarity nothing to do with filter_fields in JmodelList.
To custom filter a field in a forms xml file for a component is quite straight forward. I can add a helper class to controller.php and use a static method on my field using the 'filter=' attribute. Example: filter="GalleryHelper::filterMedia" (Example is a variation of: filter="LanguagesHelper::filterText" located as of Joomla 3.4.5: administrator/components/com_languages/models/forms/override.xml line:20).
I've found it difficult to do the same in a stand alone module. In this case you can use custom fields and rules but you're still limited to the standard filters using the filterField() method in JForm class (located as of Joomla 3.4.5: libraries/joomla/form/form.php Joomla 3.4.5 line: 1224).
A work around is to use a plugin since com_modules supports 'on before save'. This isn't ideal since you need to two extensions to achieve the result and you've got another plugin adding to 'on before save' queue.
My proposal is to add a new class called 'JFormFilter' located in libraries/joomla/form/filter.php and it works more or less the same way JFormRule does but with existing backwards compatability. This would be, least in my mind ideal. The only concern maybe a considerable performance hit?
I'm still not entirely familiar how JFormRule integrates but I would be happy to lay the ground work for this addition if the community would want it?
Labels |
Added:
?
|
Labels |
Added:
?
|
Category | ⇒ | Feature Request |
Hi, Sorry for the super late response!
I assume you're refering to something like this (mod_test.xml for example):
<config>
<fields name="params">
<fieldset name="basic" addfieldpath="/modules/mod_test/models/fields" addrulepath="/modules/mod_test/models/rules">
/libraries/joomla/form/form.php has a function called syncPaths() (line 1867 as of Joomla 3.5.1) that supports addfieldpath
, addrulepath
and addformpath
however there's no addfilterpath
option which is critical if you want to do something that's outside Joomla's default filters.
Agreed regarding call_user_func, If I recall correctly it only works if your running from custom fields inside your component (com_test for example). Stilll it seems possible, I'll try and come up with a working prototype.
@CerberusMkII do you have a working prototype?
Status | New | ⇒ | Information Required |
Status | Information Required | ⇒ | Closed - No Reply |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-05-27 08:10:24 |
Closed_By | ⇒ | franz-wohlkoenig |
Status | Closed - No Reply | ⇒ | Closed |
Closed_By | franz-wohlkoenig | ⇒ | joomla-cms-bot |
Set to "closed" on behalf of @franz-wohlkoenig by The JTracker Application at issues.joomla.org/joomla-cms/8444
This has been closed due to lack of response to the requests above - it can always be reopened in the future if it is updated.
Hi, sorry for the incredibly late response. I'll try and have something before year end if possible.
You don't necessarily need a new class. The Module Manager (and inherently other parts of the system) really need a way to be able to load files from extensions to make these features work more reliably. The
addXXXpath
attributes on the XML schema are already reliable enough for custom form fields and rules, but because of how callback functions for filters can be defined it isn't as straightforward to extract something out of that and load it.