Repeatable Form Field

131 views
Skip to first unread message

l...@wigginsclan.net

unread,
Jun 10, 2017, 7:20:12 AM6/10/17
to Joomla! General Development
Hi,

In my custom component, I had created a custom field that was based on the repeatable JForm field.

Up until the 3.7 upgrade, it was working really well.

Post upgrade I have noticed that it is duplicating the chzn drop down inputs contained in the repeatable elements.

I have debugged it down to the following function causing the problem:
[code]
self.fixScripts = function($row){
        // chosen hack
        if($.fn.chosen){
        $row.find('select').chosen()
        }

        //color picker
        $row.find('.minicolors').each(function() {
        var $el = $(this);
        $el.minicolors({
control: $el.attr('data-control') || 'hue',
position: $el.attr('data-position') || 'right',
theme: 'bootstrap'
});
});

        // fix media field
        $row.find('a[onclick*="jInsertFieldValue"]').each(function(){
        var $el = $(this),
        inputId = $el.siblings('input[type="text"]').attr('id'),
        $select = $el.prev(),
        oldHref = $select.attr('href');
        // update the clear button
        $el.attr('onclick', "jInsertFieldValue('', '" + inputId + "');return false;")
        // update select button
        $select.attr('href', oldHref.replace(/&fieldid=(.+)&/, '&fieldid=' + inputId + '&'));
        });

        // another modals
        if(window.SqueezeBox){
        SqueezeBox.assign($row.find('a.modal').get(), {parse: 'rel'});
        }
        };
[/code]

Primarily it is this line within the above function:

[code]
// chosen hack
if($.fn.chosen){
$row.find('select').chosen()
}
[/code]

I have looked in the repeatable script file in 3.7 the offending lines are not in the version 3.7 code as it was in the 3.6.5 version.

However, if I remove that line, my selected values are not displayed properly.

Is anyone able to shed any light on how I fix this?

Thanks

Lee

Walt Sorensen aka photodude

unread,
Jun 10, 2017, 3:17:17 PM6/10/17
to Joomla! General Development
Unfortunately, repeatable fields are just broken, and deprecated. as of J3.7 You should use the subform field any time you need a field that will repeat.

the key with subform to get the repeating function is "If attribute multiple set to true then the included form will be repeatable."

l...@wigginsclan.net

unread,
Jun 12, 2017, 10:34:37 PM6/12/17
to Joomla! General Development
Hi,

Thanks for your reply. I will update to use subform instead.

Thanks again

Lee
Reply all
Reply to author
Forward
0 new messages