Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: [FIXED] v2.0: 2 File fields with diff allowed mime types

[FIXED] v2.0: 2 File fields with diff allowed mime types 10 Oct 2012 10:45 #4356

  • nvgogh
  • nvgogh's Avatar
  • Offline
  • Junior Member
  • Posts: 22
  • Thank you received: 2
  • Karma: 0
I have a table with 2 fields, each has it's own allowed mime type.

Field 1: Allowed type GPX
Field 2: Allowed type DOC + PDF

However the frontend form applies the same allowed types on both fields
It takes the allowed types of the last file field in the form and applies it also to the previous one
I tried it by swapping the fields in the form (also in the table but that didn't matter)

Field 1: Allowed type DOC + PDF
Field 2: Allowed type DOC + PDF

and

Field 2: Allowed type GPX
Field 1: Allowed type GPX
The administrator has disabled public write access.

Re: v2.0: 2 File fields with diff allowed mime types 10 Oct 2012 11:13 #4357

  • BTB300
  • BTB300's Avatar
  • Online
  • Moderator
  • Posts: 415
  • Thank you received: 131
  • Karma: 47
Hi There,
While it may not be a solution for the multiple file MIME types issue but worth a try

just thought i would let you know something that was solved for pbianco about .gpx and file upload problems
pbianco wrote:
Hi all,
I was already using Joomla 2.5, but JCook build 1.5.
Following BTB300's suggestion, I have tried with JCook build 2.0, and now it works!!!!
In case anybody needs to do the same, I have used as MIME extension application/xml for gpx.
Thanks a lot
Last Edit: 10 Oct 2012 11:15 by BTB300.
The administrator has disabled public write access.

Re: v2.0: 2 File fields with diff allowed mime types 10 Oct 2012 11:17 #4358

  • nvgogh
  • nvgogh's Avatar
  • Offline
  • Junior Member
  • Posts: 22
  • Thank you received: 2
  • Karma: 0
Thank BTB330, at least I'll change the mime type according to the suggestion
The administrator has disabled public write access.
The following user(s) said Thank You: BTB300

Re: v2.0: 2 File fields with diff allowed mime types 16 Oct 2012 13:20 #4561

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 985
  • Karma: 140
Stange, I cannot get this one.

Where is the validation error ? PHP or JS ?

Can you copy your postSaveHook() function from your concerned item controller ?
It contains these allowed extensions.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: v2.0: 2 File fields with diff allowed mime types 17 Oct 2012 05:01 #4604

  • nvgogh
  • nvgogh's Avatar
  • Offline
  • Junior Member
  • Posts: 22
  • Thank you received: 2
  • Karma: 0
It's a validation error so I assume a JS issue, maybe the allowed types are put on all the file type controls instead of a specific id? (but that's just guessing)

What I did, I have in 1 table 2 file fields

Field labelled "GPX Bestand" which has an allowed type of GPX ( I added that manually to the list)
Field labelled "Papieren versie" which has the allowed types of DOC + PDF

If I run it in the sandbox then this is my edit screen (via administrator)

Field labelled "GPX Bestand" with an invalid file extension




Field labelled "Papieren versie" with an invalid file extension

Last Edit: 17 Oct 2012 05:01 by nvgogh.
The administrator has disabled public write access.

Re: v2.0: 2 File fields with diff allowed mime types 17 Oct 2012 06:57 #4608

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Do you get any JS errors in your console (browser dev tools)or any errors printed on the screen from php? If so please could you share them...

Also, I noticed once that for some reason (probably my error) the default list of image extensions were there but unchecked... I'm not saying that this is the case for you however, its always worth a quick look. In this instance, I rechecked the options on the field and rebuilt - worked fine.

Thanks,

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: v2.0: 2 File fields with diff allowed mime types 17 Oct 2012 07:19 #4609

  • nvgogh
  • nvgogh's Avatar
  • Offline
  • Junior Member
  • Posts: 22
  • Thank you received: 2
  • Karma: 0
Saved the allowed types again on the table column in the designer.
Then I went back to the edit page and had Firebug running but no JS errors we logged by Firebug.
The issue was still there.
The administrator has disabled public write access.

Re: v2.0: 2 File fields with diff allowed mime types 17 Oct 2012 07:22 #4610

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Do you have all Warnings and errors visible in debugger - I mean enabled?

*******edit
Similar to your servver/dev environment, you can suppress certain types of messages. Typically in your console, there'll be a long list of these that you can 'tick' on.

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
Last Edit: 17 Oct 2012 07:29 by JoomGuy.
The administrator has disabled public write access.

Re: v2.0: 2 File fields with diff allowed mime types 17 Oct 2012 07:28 #4611

  • nvgogh
  • nvgogh's Avatar
  • Offline
  • Junior Member
  • Posts: 22
  • Thank you received: 2
  • Karma: 0
Yes I have the 'All' function allways in Firebug

The administrator has disabled public write access.

Re: v2.0: 2 File fields with diff allowed mime types 17 Oct 2012 07:30 #4612

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
In that case, what about your server/dev environment's error reporting? Set to all too?

*****Edit
Sorry, I can see that you're in cook sandbox from your screenshots... Can you test locally?
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
Last Edit: 17 Oct 2012 07:36 by JoomGuy. Reason: *****Edit
The administrator has disabled public write access.

Re: v2.0: 2 File fields with diff allowed mime types 17 Oct 2012 07:36 #4613

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
previous edited
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: v2.0: 2 File fields with diff allowed mime types 17 Oct 2012 07:38 #4614

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
In your screenshot, what's the extension of the file you're trying to upload - I can't quite make it out?
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: v2.0: 2 File fields with diff allowed mime types 17 Oct 2012 09:24 #4616

  • nvgogh
  • nvgogh's Avatar
  • Offline
  • Junior Member
  • Posts: 22
  • Thank you received: 2
  • Karma: 0
Oke I did some sniffing around in the code of the component and I see two issues which cause this behavior

Issue 1:

The form xml (in my cause toertocht.xml) has an incompatiblity with the allowed types selection I made in the builder

<field name="gpx"
label="TOERPROGRAMMA_FIELD_GPX_BESTAND"
alias="gpx"
filter="STRING"
class="validate[custom]" validate="file" indirect="true" root="[DIR_TOERTOCHTEN_GPX]" type="ckfile" allowedExtensions="*.gpx"/> <field name="document" label="TOERPROGRAMMA_FIELD_PAPIEREN_VERSIE" alias="document" filter="STRING" class="validate[custom[file]]" validate="file" indirect="true" root="[DIR_TOERTOCHTEN_DOCUMENT]" type="ckfile" allowedExtensions="*.doc|*.pdf[color=#ff0000][b]|*.gpx[/b][/color]"/> What's that last GPX doing there? It's not selected in my builder (only for the other file control) [img]http://imageshack.us/a/img90/6971/capturecot.png[/img] Now this I can manually change, so that's no showstopper just a bit annoying (and still a bug in the builder) [b][u]Issue 2:[/u][/b] In the html file which is generated to show me my edit form for the toertocht model the validator javascript is generated. However the validator rule name/key is not made unique ----- snippet from my html ------ jQuery.validationEngineLanguage.allRules.file = { "regex" : new RegExp("\.(gpx)$", 'i'), "alertText" : '<span class="msg-prefix">• </span>Allowed files : <br/>*.gpx' } jQuery.validationEngineLanguage.allRules.file = { "regex" : new RegExp("\.(doc|pdf|gpx)$", 'i'), "alertText" : '<span class="msg-prefix">• </span>Allowed files : <br/>*.doc<br/>*.pdf<br/>*.gpx' } ----- end snippet from my html ------ meaning the last rule will allways the rule which is applied to all file input controls which are in the form. (The gpx in the last file rule is caused by the configuration in the xml file being wrong)[file]]"
validate="file"
indirect="true"
root="[DIR_TOERTOCHTEN_GPX]"
type="ckfile"
allowedExtensions="*.gpx"/>

<field name="document"
label="TOERPROGRAMMA_FIELD_PAPIEREN_VERSIE"
alias="document"
filter="STRING"
class="validate[custom]" validate="file" indirect="true" root="[DIR_TOERTOCHTEN_DOCUMENT]" type="ckfile" allowedExtensions="*.doc|*.pdf[color=#ff0000][b]|*.gpx[/b][/color]"/> What's that last GPX doing there? It's not selected in my builder (only for the other file control) [img]http://imageshack.us/a/img90/6971/capturecot.png[/img] Now this I can manually change, so that's no showstopper just a bit annoying (and still a bug in the builder) [b][u]Issue 2:[/u][/b] In the html file which is generated to show me my edit form for the toertocht model the validator javascript is generated. However the validator rule name/key is not made unique ----- snippet from my html ------ jQuery.validationEngineLanguage.allRules.file = { "regex" : new RegExp("\.(gpx)$", 'i'), "alertText" : '<span class="msg-prefix">• </span>Allowed files : <br/>*.gpx' } jQuery.validationEngineLanguage.allRules.file = { "regex" : new RegExp("\.(doc|pdf|gpx)$", 'i'), "alertText" : '<span class="msg-prefix">• </span>Allowed files : <br/>*.doc<br/>*.pdf<br/>*.gpx' } ----- end snippet from my html ------ meaning the last rule will allways the rule which is applied to all file input controls which are in the form. (The gpx in the last file rule is caused by the configuration in the xml file being wrong)[file]]"
validate="file"
indirect="true"
root="[DIR_TOERTOCHTEN_DOCUMENT]"
type="ckfile"
allowedExtensions="*.doc|*.pdf|*.gpx"/>


What's that last GPX doing there? It's not selected in my builder (only for the other file control)


Now this I can manually change, so that's no showstopper just a bit annoying (and still a bug in the builder)


Issue 2:

In the html file which is generated to show me my edit form for the toertocht model the validator javascript is generated. However the validator rule name/key is not made unique

snippet from my html
jQuery.validationEngineLanguage.allRules.file = {
"regex" : new RegExp("\.(gpx)$", 'i'),
"alertText" : '<span class="msg-prefix">• </span>Allowed files : <br/>*.gpx'
}
jQuery.validationEngineLanguage.allRules.file = {
"regex" : new RegExp("\.(doc|pdf|gpx)$", 'i'),
"alertText" : '<span class="msg-prefix">• </span>Allowed files : <br/>*.doc<br/>*.pdf<br/>*.gpx'
}
end snippet from my html

meaning the last rule will allways the rule which is applied to all file input controls which are in the form.
(The gpx in the last file rule is caused by the configuration in the xml file being wrong)
The administrator has disabled public write access.

Re: v2.0: 2 File fields with diff allowed mime types 17 Oct 2012 10:26 #4617

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
nvgogh wrote:
Issue 1: ...
This is the behaviour I described previously... Try re-setting + rebuildingnvgogh wrote:
Issue 2: ...
I believe that this is due to the image uploader's intended use, i.e. I believe that it was not implemented specifically to handle different file formats on the same page.

I wonder if there's something tht @admin could do to get around this?

POSSIBLE WORKAROUND
  1. Find your rules files... (administrator/models/rules)
  2. Copy the file.php and and rename to something unique
  3. Adapt the file to suit your needs
  4. update your xml accordingly

Let us know how you get on with this?

Hope it helps!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: v2.0: 2 File fields with diff allowed mime types 17 Oct 2012 10:29 #4618

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Also, I wonder what the difference would be if you just tried using exploded fields in your form instead...?

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.207 seconds

Get Started