Welcome, Guest
Username: Password: Remember me

TOPIC: [FIXED] required for ckcombo type

required for ckcombo type 17 Mar 2016 14:14 #13850

  • albert
  • albert's Avatar
  • Offline
  • Senior Member
  • Posts: 70
  • Thank you received: 2
  • Karma: 2
Hi,

I did a component with a few combos and text fields,
now i should make them compulsory, so i go to com_name/models/forms/name.xml
and i add to the
<field name="observations"
...
required="true"
type="cktextarea"/>

and it works fine, if the field is empty i receive the warning

When i try to make the same for a type="ckcombo" (select list), it doesn't work, even empty is validating the form.
I tried to add several combinations of:
required="true"
validate="numeric"
class="required validate-numeric"

but it never works

can u help me please ?

Albert
The administrator has disabled public write access.

required for ckcombo type 18 Mar 2016 13:45 #13851

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

Read this topic:
www.j-cook.pro/index.php/forum/19-new-ti...elect-not-validating

Will probably help you solve it.
The administrator has disabled public write access.

required for ckcombo type 18 Mar 2016 14:00 #13852

  • albert
  • albert's Avatar
  • Offline
  • Senior Member
  • Posts: 70
  • Thank you received: 2
  • Karma: 2
Hi,

Thanks but i already tried
i added:
<script>
(function($){
$("#adminForm").validationEngine('attach',{prettySelect:true,useSuffix:"_chzn"});
})(jQuery)
</script>

i also tried to comment out
//JHtml::_('formbehavior.chosen', 'select');
from helper.php :: headerDeclarations()

and nothing, when i save the form, the combo with required="true" is validated even without selecting any item
The administrator has disabled public write access.

required for ckcombo type 18 Mar 2016 14:19 #13853

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Yes, that is actuaclly wrong

It should be:
<script>
(function($){
	$(document).ready(function () {
			$("#adminForm").validationEngine('attach',{prettySelect:true,useSuffix:"_chzn"});
	});
})(jQuery)
</script>

Mind the: $(document).ready(function () {
The administrator has disabled public write access.

required for ckcombo type 18 Mar 2016 15:43 #13854

  • albert
  • albert's Avatar
  • Offline
  • Senior Member
  • Posts: 70
  • Thank you received: 2
  • Karma: 2
Hi, it continue without working, i placed on:
com_xxx/fork/views/xxx/tmpl/xxx.php


defined('_JEXEC') or die('Restricted access');


ComprasHelper::headerDeclarations();
//Load the formvalidator scripts requirements.
JDom::_('html.toolbar');
?>
<script language="javascript" type="text/javascript">
//Secure the user navigation on the page, in order preserve datas.
var holdForm = true;
/*window.onbeforeunload = function closeIt(){ if (holdForm) return false;};*/

(function($){
$(document).ready(function () {
$("#adminForm").validationEngine('attach',{prettySelect:true,useSuffix:"_chzn"});
});
})(jQuery)

</script>
<?php
..
.
.

but it continues without validating
if i inspect the code, i do not see the required, i see:
<select id="jform_ip_id" name="jform[ip_id]" class="chzn-done" style="display: none;">
<option value="" selected="selected">- Select IP -</option>
<option value="952">A</option>
<option value="1371">B</option>
...
</select>
The administrator has disabled public write access.

required for ckcombo type 18 Mar 2016 20:41 #13855

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
A little further down there will probably be (when inspecting your html) someting like:
<div class="chzn-container chzn-container-single chzn-container-single-nosearch" style="width: 220px;" title="" id="jform_ip_id_chzn"><a class="chzn-single" tabindex="-1"><span>- Select IP -</span>
That is where the _chzn suffix is.

I have my piece op code in the _form.php, just after
<?php $fieldSet = $this->form->getFieldset('xxxx.form');?>

Does a jquery error show up in the console perhaps?

Hope it helps
Last Edit: 18 Mar 2016 20:42 by Romkabouter.
The administrator has disabled public write access.
The following user(s) said Thank You: admin

required for ckcombo type 23 Mar 2016 10:37 #13865

  • albert
  • albert's Avatar
  • Offline
  • Senior Member
  • Posts: 70
  • Thank you received: 2
  • Karma: 2
Hi, now by adding the code i get:


<select id="jform_ip_id" name="jform[ip_id]" required="required">
<option value="" selected="selected">- Select ICMAB IP -</option>
....
</select>

when i click on the selct box the border is red (good signal), but when i click on submit, the form is accepting the empty value !!
it is very strange because another fields (for instance a text one) is validating properly

no messages on the console

we are getting close ...
The administrator has disabled public write access.

required for ckcombo type 02 May 2016 13:36 #13926

  • albert
  • albert's Avatar
  • Offline
  • Senior Member
  • Posts: 70
  • Thank you received: 2
  • Karma: 2
any idea ??
i am still stuck with no validation
The administrator has disabled public write access.

required for ckcombo type 05 May 2016 20:38 #13928

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
If it is no problem for you, please attach an installable zip file of your component or send me an email on This email address is being protected from spambots. You need JavaScript enabled to view it.
I can then install it and see what is the problem.

Also I need the forked files offcourse :)
The administrator has disabled public write access.
The following user(s) said Thank You: albert

required for ckcombo type 09 May 2016 09:04 #13929

  • albert
  • albert's Avatar
  • Offline
  • Senior Member
  • Posts: 70
  • Thank you received: 2
  • Karma: 2
Hi,

Now i made it work, i started from scratch again!
maybe when i did the fork i did something wrong !

Apology for so many emails.

Albert
The administrator has disabled public write access.

required for ckcombo type 09 May 2016 09:11 #13930

  • Romkabouter
  • Romkabouter's Avatar
  • Offline
  • Elite Member
  • Posts: 310
  • Thank you received: 131
  • Karma: 48
Great, no worries. We are here to help to the best we can :)
The administrator has disabled public write access.

required for ckcombo type 09 May 2016 10:47 #13934

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Hi Albert,
The fix of Romkabouter is now integrated in the new version.
You can remove your fork. Sorry, I was too late on this one it could have avoid you some work.

Cheers.
Coding is now a piece of cake
The administrator has disabled public write access.
Time to create page: 0.169 seconds

Get Started