? Pending

User tests: Successful: Unsuccessful:

avatar piotrmocko
piotrmocko
4 Mar 2015

If element is a "fieldset" with class "radio" or "checkboxes", then use value of checked input child instead of itself, as fieldset does not have a value. It would allow to have validation handlers also for radio and checkboxes group.

TEST
An example with radio options where if article is featured it requires some tags

  • Enable debug in Global Configuration as patch contains only uncompressed file
  • Edit file administrator/components/com_content/views/article/tmpl/edit.php
  • At the end of file put a test code
  • Go to new article view
  • Select option that article is featured and do not select any tags
  • Try to save
  • You will get error with Featured field
  • Select some tags
  • Try to save
  • You will not get that error again

Test code

<script type="text/javascript">
jQuery(document).ready(function() {
    jQuery("#jform_featured").addClass("validate-featured");
    document.formvalidator.setHandler("featured", function(value, element) {
        var tags = jQuery("#jform_tags").val() || [];
        return (value == 0 || (value == 1 && tags.length > 0));
    });
});
</script>

Which tool do you use in Joomla to compress JS, that I could create one?

avatar piotrmocko piotrmocko - open - 4 Mar 2015
avatar joomla-cms-bot joomla-cms-bot - change - 4 Mar 2015
Labels Added: ?
avatar brianteeman brianteeman - change - 4 Mar 2015
Category JavaScript
avatar brianteeman brianteeman - change - 11 Mar 2016
Category JavaScript Fields JavaScript
avatar conconnl conconnl - test_item - 25 Jun 2016 - Tested unsuccessfully
avatar conconnl
conconnl - comment - 25 Jun 2016

I have tested this item ? unsuccessfully on 3c63f15

I wasn't able to reproduce an error on the latest Staging


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

avatar mxkmp29 mxkmp29 - test_item - 1 Aug 2016 - Tested unsuccessfully
avatar mxkmp29
mxkmp29 - comment - 1 Aug 2016

I have tested this item ? unsuccessfully on 3c63f15

I tested @icampus,

I wasn't able to reproduce the error on the latest stage. After I selected the option that the article is featured and pressed save Joomla only throw an error because there was no title. I entered a title and press save. No Errors and the article was saved.


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

avatar Schmidie64
Schmidie64 - comment - 2 Aug 2016

@icampus I have tested this Item unsuccessfully

I wasn't able to reproduce the error. After i selected the Featured field and i try to save the article, no error appeared and the article was saved successfully.

avatar piotrmocko
piotrmocko - comment - 2 Aug 2016

I have just fixed the patch and test it again and it is working for me.

Without this patch the test scenario should result in no error and the article should be saved.
After applying the patch the test scenario should result in a validation error message.

avatar Schmidie64 Schmidie64 - test_item - 2 Aug 2016 - Tested unsuccessfully
avatar Schmidie64
Schmidie64 - comment - 2 Aug 2016

I have tested this item ? unsuccessfully on da282e3

@icampus I have tested this Item unsuccessfully

I wasn't able to reproduce the error. After i selected the Featured field and i try to save the article, no error appeared and the article was saved successfully.


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

avatar piotrmocko
piotrmocko - comment - 2 Aug 2016

Check in your browser if the file media/system/js/validate-uncompressed.js has been reloaded and you see the changes in it
and if the element #jform_featured has the class validate-featured

avatar roland-d
roland-d - comment - 2 Aug 2016

@Schmidie64 @mxkmp29 Can you test again following the instructions pointed out by Piotr?


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

avatar ggppdk
ggppdk - comment - 2 Aug 2016

Hello, i looked at your code and i see:

$el.find('input:checked')

which, will return a jQuery collection which contains a list of matched elements
(in this case the checked ones)

then you call on it .val()

elValue = $el.find('input:checked').val();

which will get the value only from the first matched element
(or it will return undefined if none checkbox is checked or none radio is selected)

  • and then you pass it to the validation hander, is that what you want to do ? only pass the first value ?

Propably you want to do (which will work in radio set too):

elValue = [];
$el.find('input:checked').each(function(){            
    elValue.push($(this).val());
});

or faster something like:

var options = el.getElementsByTagName('input');
var elValue = [], i;
for (i=0; i<options.length; i++)
{
    if (options[i].checked) elValue.push(options[i].value);
}

then you can do something like:

!!elValue && elValue.length && handlers[handler].exec(elValue, $el) !== true

A custom handler should be providen with all the values and not only the first one ?

avatar piotrmocko
piotrmocko - comment - 2 Aug 2016

You are right. It would be better to pass an array of values if it is a fieldset of checkboxes, but for radio I think that it would be enough to pass a single value as for other types of elements. I will make changes and let you know.

avatar Schmidie64 Schmidie64 - test_item - 2 Aug 2016 - Tested unsuccessfully
avatar Schmidie64
Schmidie64 - comment - 2 Aug 2016

I have tested this item ? unsuccessfully on da282e3

@icampus
I have made the Test again and nothing changed. I didn't get an error message. I tried to save the article, no error appeared.


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

avatar roland-d
roland-d - comment - 3 Nov 2016

Hello @piotrmocko

Thank you for your contribution.

The last comment here was on August 2nd. Can you update this pull request?
If no reply is received within 4 weeks we will close this issue.

Thanks for understanding!


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

avatar franz-wohlkoenig
franz-wohlkoenig - comment - 6 Jan 2017

@roland-d 4 Weeks are gone.

avatar jeckodevelopment jeckodevelopment - change - 6 Jan 2017
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2017-01-06 15:05:16
Closed_By jeckodevelopment
avatar jeckodevelopment jeckodevelopment - close - 6 Jan 2017

Add a Comment

Login with GitHub to post a comment