Welcome, Guest
Username: Password: Remember me

TOPIC: [FIXED] Required FK select not validating

Required FK select not validating 03 Nov 2015 15:40 #13654

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Hi admin,

For this problem I have created an isolated problem project, FKTest.
It has two tables, table1 and table2.
Table2 has a FK field to table1, set as required

Adding an item to table2 and leaving the FK field empty, does not trigger an error.

Expected behavior: Clicking save will trigger error when no FK value is selected
Actual behavior: Clicking save saves item and leaves FK value empty
The administrator has disabled public write access.

Required FK select not validating 03 Nov 2015 15:43 #13655

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Some debugging what I did:

In the jquery.validationEngine.js there is a funciion _validateField.
In this function around line 460 the hidden property is checked: field.is(":hidden")
if (field.is(":hidden") && !options.prettySelect || field.parent().is(":hidden"))
 return false;
This is true for the select input, I did not investigate further.
The administrator has disabled public write access.

Required FK select not validating 05 Nov 2015 19:34 #13657

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
JS validation

'chosen' library is causing the problem.
In :
helper.php :: headerDeclarations()

If you comment this line, then it works.
JHtml::_('formbehavior.chosen', 'select');

But the problem, is that will disable ALL select fields. I have no idea how to avoid chosen for a particular field.
For the JS, I will not dig more in because I don't want to hack the third-part library, and secondly this might be deprecated in the coming 'Pure' version.

PHP validation
In an other hand, it should at least validate at php level, this is a problem in facts.
I am checking and I tell you.
Coding is now a piece of cake
The administrator has disabled public write access.

Required FK select not validating 06 Nov 2015 09:02 #13658

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Do not make it a priority for me, I have created a workaround.
It is better I think to put you effort in the next pure version.

I will try the chosen statement and see what it brings.

Thanx
The administrator has disabled public write access.

Required FK select not validating 11 Dec 2015 15:18 #13741

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
I have fixed it by adding
<script>
(function($){	
	$("#adminForm").validationEngine('attach',{prettySelect:true,useSuffix:"_chzn"});
})(jQuery)
</script>

in the form for the item (in my case component/fork/view/record/tpml/createrecord_form.php)
But I will take it one step further and fork the headerDeclaration, so I can utilize this on every form.
I did not test it with a relation field, but will soon

Validation also does not work on textarea with rich text editor (ajax validation that is, validation itself works)
Last Edit: 11 Dec 2015 19:15 by Romkabouter.
The administrator has disabled public write access.

Required FK select not validating 04 Jan 2016 19:38 #13760

  • MorganL
  • MorganL's Avatar
  • Offline
  • Platinum Member
  • Posts: 438
  • Thank you received: 53
  • Karma: 15
Thats works BEAUTIFULLY for the non-ajax select box, many thanks!

Any ideas on fixing the same issue with ajax selectors?
Morgan Leecy MCSE

Novell / Linux
PHP. MYSQL, Apache, node.js
Coldfusion, JQuery, HTML5
Joomla
The administrator has disabled public write access.

Required FK select not validating 05 Jan 2016 10:04 #13761

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Great :)
Never used Ajax combo myself :D

Can you write down your desgin so I can recreate and test?
The administrator has disabled public write access.

Required FK select not validating 05 Jan 2016 15:16 #13762

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Good question.
It is possible as said by Romkabouter, that the jQuery conflict is the problem.

The ajax combo is gonna work much better in the "Pure" version, with a new Ajax mini framework.
This part is already done in my hands, but I cannot publish yet.

For me it seems working well on a fresh install, but you can avoid it at the moment if you have problems.
This is not Joomla standard. I have made this 'added' feature to answer the needs of some very engaged followers customers, but I don't like it that much because with Joomla! it is a pain to achieve it properly. I had many issues there in the past and still it continues to be unstable. So I rewrited all.

In the 'Pure' version, those ajax fields are defined in XML file, and handled by superclass. It is a beauty.
Can't wait to show you that stuff. ... Just hold your breath (again) for a while.
Coding is now a piece of cake
The administrator has disabled public write access.

Required FK select not validating 09 May 2016 10:45 #13933

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
I have included your code (Romkabouter). It is really good one in facts !!!
It even works for AJAX combos.
This is a real combo !
One of the best fix ever ! I was digging that for so long...
K+++

Fixed since 2.8.2
Coding is now a piece of cake
The administrator has disabled public write access.
The following user(s) said Thank You: Romkabouter
Time to create page: 0.073 seconds

Get Started