User tests: Successful: Unsuccessful:
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
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?
Labels |
Added:
?
|
Category | ⇒ | JavaScript |
Category | JavaScript | ⇒ | Fields JavaScript |
I have tested this item
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.
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.
I have tested this item
@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.
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
@Schmidie64 @mxkmp29 Can you test again following the instructions pointed out by Piotr?
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)
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 ?
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.
I have tested this item
@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.
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!
Status | Pending | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-01-06 15:05:16 |
Closed_By | ⇒ | jeckodevelopment |
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.