? ?
avatar CerberusMkII
CerberusMkII
16 Nov 2015

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.

Proposal

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?

avatar CerberusMkII CerberusMkII - open - 16 Nov 2015
avatar zero-24 zero-24 - change - 17 Nov 2015
Labels Added: ?
avatar brianteeman brianteeman - change - 18 Nov 2015
Labels Added: ?
avatar zero-24 zero-24 - change - 25 Nov 2015
Category Feature Request
avatar mbabker
mbabker - comment - 8 May 2016

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.

avatar CerberusMkII
CerberusMkII - comment - 12 Jul 2016

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.

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 6 Apr 2017

@CerberusMkII do you have a working prototype?


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/8444.

avatar joomla-cms-bot joomla-cms-bot - change - 6 Apr 2017
The description was changed
avatar joomla-cms-bot joomla-cms-bot - edited - 6 Apr 2017
avatar franz-wohlkoenig franz-wohlkoenig - change - 6 Apr 2017
Status New Information Required
avatar franz-wohlkoenig franz-wohlkoenig - change - 27 May 2017
Status Information Required Closed - No Reply
Closed_Date 0000-00-00 00:00:00 2017-05-27 08:10:24
Closed_By franz-wohlkoenig
avatar joomla-cms-bot joomla-cms-bot - change - 27 May 2017
Status Closed - No Reply Closed
Closed_By franz-wohlkoenig joomla-cms-bot
avatar joomla-cms-bot joomla-cms-bot - close - 27 May 2017
avatar joomla-cms-bot
joomla-cms-bot - comment - 27 May 2017
avatar franz-wohlkoenig
franz-wohlkoenig - comment - 27 May 2017

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.

avatar CerberusMkII
CerberusMkII - comment - 4 Oct 2017

Hi, sorry for the incredibly late response. I'll try and have something before year end if possible.

Add a Comment

Login with GitHub to post a comment