Welcome, Guest
Username: Password: Remember me

TOPIC: [FIXED] JQuery & Form Validation Errors in Administrator

[FIXED] JQuery & Form Validation Errors in Administrator 24 Sep 2012 11:49 #3941

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi @admin,
--PLEASE REMOVE THIS THREAD AS IT WAS POSTED IN WRONG BOARD
Now posted in correct forum, DEBUG->NEW TICKETS
I'm experiencing some issues in the back-end form for my projects table/view...

I've switched to v2.0 to leverage some of the added functionality and in the hope that it may have fixed my datetime issue. Also, FYI, I'm using JQuery as JS Framework and Model for DB automations. Also, I've tried both locally and in sandbox with the same results.

Please see image for display of errors...
  1. Cancel button does not work and reveals a JQuery error - jQuery validation rules are not loaded, plz add localization files to the page
  2. Year field validation doesn't cause error when less than 4 digits entered despite it being a properly formed regex that works perfectly in the builder
  3. Places (Qty) field validation doesn't cause error when numbers outside the range 1-100 entered - again, despite it being a properly formed regex that works in the builder
  4. Entry Date (datetime field) is out of line and the calendar button doesn't reveal an input. I've tried deleting the field and re-adding, rebuilding the component but still no joy.

Please help with this!

Thanks,

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

Re: JQuery & Form Validation Errors in Administrator 24 Sep 2012 13:10 #3947

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
It is a problem in your regex.

Can you show me this regex ?

One thing to know :
Entering the regex in the builder is not guaranteed. It helps, but sometimes do not pass.

This is due to the security of the builder wich is escaping the regex in a complex process. In reallity, some chars are not allowed if I remember.

My advice, check well all the regex present in the rules files (models/rules/xxxx.php)
Coding is now a piece of cake
Last Edit: 24 Sep 2012 13:10 by admin.
The administrator has disabled public write access.
The following user(s) said Thank You: JoomGuy

Re: JQuery & Form Validation Errors in Administrator 24 Sep 2012 13:29 #3951

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Thanks admin!!!

I noticed that the regex was an issue by looking at the source/scripts but in all honesty, I thought that it was a rendering error in the output component as opposed to the regex itself because it was working in the builder...

Here are the 2 regex validations I'm using:
  1. Field: year - ^20\d{2}$ - validates years 20xx
  2. Field: places_qty - ^([1-9]|[1-9][0-9]|100)$ - validates numers 1-100
How can I change these to suit?

Could these errors be causing the other issues?

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: JQuery & Form Validation Errors in Administrator 24 Sep 2012 13:44 #3953

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
In V2.0, there is only one place for them : models/rules/xxx.php

The regex is a protected var in the rule class.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: JQuery & Form Validation Errors in Administrator 24 Sep 2012 13:47 #3954

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi,

Sure, I found them but can't really see anything wrong with them...
protected $regex = '^([1-9]|[1-9][0-9]|100)$'; // range 1-100
protected $regex = '^20\d{2}$'; // Year

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: JQuery & Form Validation Errors in Administrator 24 Sep 2012 14:41 #3962

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi admin the only thing I can see that is different at all is;

In the builder, I'd assigned a handler name for my regex "int_range1_100" however, in the rules classes, this had been converted to "intrange1100".

Whilst I'm sure that this has nothing to do with the issue, I'm really struggling to work out what's wrong with the regexs posted above.

Any thoughts?

Please could you tell me how I need to change my regexs (previous post) in order to get them to work?

Thanks,

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

Re: JQuery & Form Validation Errors in Administrator 25 Sep 2012 10:20 #3971

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi Admin,

Right, I've made some changes in an attempt to pin-point the cause of the problem. I've;
  1. Removed the regex on both fields in question.
  2. Cleared browser cache
  3. Re-built the project files
  4. Cleared browser cache again
  5. Re-built and installed the component in the sandbox
None of these measures have had any effect whatsoever except to say that obviously, now there is no regex on the 2 fields, they behave as expected.

The issue with the cancel button still remans as do the JS errors described in my first post.

Also, 2 more issues have appeared -
When trying to save a new record to the projects table I experienced some very unusual behaviour.
  1. I selected a '.exe' file in my image uploader to test the allowed formats that are set to the standard image formats only. As you can see from the picture below, it saved the record regardless of it's format, saving it's filename too.
  2. Shouldn't this have failed validation and not saved the record?
  3. Despite getting a warning that the date format I entered was incorrect for the required datetime field, the record saved with an empty field
Anyway, I'm prepared to open a new thread for these later if necessary.
It is a problem in your regex.

Can you show me this regex ?

One thing to know :
Entering the regex in the builder is not guaranteed. It helps, but sometimes do not pass.

This is due to the security of the builder wich is escaping the regex in a complex process. In reallity, some chars are not allowed if I remember.

My advice, check well all the regex present in the rules files (models/rules/xxxx.php)
Also, just to confirm, the regex errors on the page:
"SyntaxError: missing ) after argument list
[Break On This Error] 	
"regex" : new RegExp("^[^\\"]*$", ''),"

As you can see, this points directly to the built-in regex rules from cook - no more custom ones on the page now as removed.

Please, I really need help with this as these javascript errors are appearing in every new table/layout I'm creating and they're really preventing me from advancing my development.

Thanks,

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
Last Edit: 25 Sep 2012 10:41 by JoomGuy. Reason: ADDED INFO
The administrator has disabled public write access.

Re: JQuery & Form Validation Errors in Administrator 25 Sep 2012 10:52 #3972

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
As a last-ditch attempt to debug this, I'm going to create a new project from scratch to see if these issues persist.

I will report back my findings ASAP.

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: JQuery & Form Validation Errors in Administrator 25 Sep 2012 11:29 #3973

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Right, so far so good...

Builder V2.0
4 basic tables added
Ajax filtering on FK field type working (wasn't in original project)

Next: ADD filters, Add regex on fields to test...

Let you know how it goes!

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: JQuery & Form Validation Errors in Administrator 25 Sep 2012 12:51 #3974

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
OK, My findings...

All of the errors discussed in my original post have now been fixed.

HOW?
Complete rebuild from scratch

DIFFICULTIES EXPERIENCED
Filters - I experienced a small bug where on a number of occasions, when trying to add a combo filter for an FK field, the image next to the parent node (table icon) seemed to disappear. Even though all of the table fields were still available and nothing was missing from any views/layouts, it was impossible to drag a any field Foreign Table->Combo Filter.

RESOLVED BY - Closing up the tables, views etc and rebuilding the files numerous times. Also had to remove the combo element itself a number of times.

CAUSE??? - Not really sure but it could be related to having deleted another element previously.

QUESTIONS @admin
    Could some of my issues have been caused from;
  1. having originally started in original version of the builder and swapping to v2.0
  2. Switching JS framework mid project
  3. ?

Further info

I did experience the issues with filters early on in the dev of my original component and in all honesty, I can't remember exactly how or in fact, if I did resolve them. Not sure if this is partially to blame for any of the other issues???

@admin Please could you take a look into my original project that I'm about to rename to "Null Project" for any inconsistencies, or irregularities. I'm sure that whatever is revealed will shed some light on some Dos and Don't's for users? For example, it may not be a good idea to switch JS frameworks once a project has been commenced...

Many 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: JQuery & Form Validation Errors in Administrator 25 Sep 2012 16:41 #3980

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
In the builder, I'd assigned a handler name for my regex "int_range1_100" however, in the rules classes, this had been converted to "intrange1100".

Joomla native do not handle spaces or underscores in rules.

Your regex problem is now fixed for the next upgrade. Stay in touch.

The problem coming from the file upload is because in V2.0, the major difference is that the upload is done AFTER storing the item. By this way, it is now possible to use the ID value to rename the files. Tag : {ID}

Checking the file extension should be done at a javascript side BEFORE to submit the form.
If the upload fail for another reason, the item will be stored anyway. I mean for the moment it works this way.
If the file is required, just add something that delete the inserted item.

So, on my end, I will add a rule for checking the extension.
And also return false if the operation fails. At least to stay on current page, or to play with redirections.
Coding is now a piece of cake
The administrator has disabled public write access.

Re: JQuery & Form Validation Errors in Administrator 25 Sep 2012 17:23 #3985

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi admin,
Joomla native do not handle spaces or underscores in rules.
In my original post about this, I was just wondering whether this could have been a reason for the error, i.e. the fact that inside the builder, it was still referred to as in_range1_100 but in the rules class it was intrange1100.
Your regex problem is now fixed for the next upgrade.
It's not actually a problem! They're working perfectly in new project - although, I am now naming them without underscores. That said, I don't think my use of underscores was even causing the problem as when got rid of my custom validations, the problem still persisted.

I just thought that it could have been partly to blame. I think that all of the issues that I faced must have been related to some weird bug created when switching JS frameworks, dropping some field or switching builder version mid-project or something??? All working fine in my new project. It would be good to know what this could actually have been if looking server-side reveals anything for you, but I don't anticipate such a find would be straight-forward.
By this way, it is now possible to use the ID value to rename the files. Tag : {ID}
How can I achieve this?

Thanks,

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

Re: JQuery & Form Validation Errors in Administrator 25 Sep 2012 17:31 #3986

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
If the field properties (File, or Image)

Property : rename

You can define a renaming pattern. (Look at the tooltip instructions)
Now {ID} is a new one (not announced yet, but working ;-)

Enjoy it ! ;-)
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: JoomGuy

Re: JQuery & Form Validation Errors in Administrator 26 Sep 2012 11:15 #4009

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Fixed.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.080 seconds

Get Started