Home Forums Plugin Support WP User Frontend Pro How to make a repeater field only have 5 options

This topic is: resolved

This topic contains 4 replies, has 2 voices, and was last updated by  Nayem 4 years, 5 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #37299

    Rupert
    Member
    Post count: 2

    Hi,

    I am trying to make the repeater field only show 5 options, and not allow the user to add 100 (if they wanted too).

    I have tried replacing this

    for (var i=0; i<5; ++i ){
                  $('.wpuf-form').on('click', 'img.wpuf-clone-field', this.cloneField);
                }

    in frontend-form.js but this just adds 5 everytime the user click the + button. Please help?

    Rupert

    #37300

    Rupert
    Member
    Post count: 2

    so this is the whole section of script:

    init: function() {
                // clone and remove repeated field
                for (var i=0; i<5; ++i ){
                  $('.wpuf-form').on('click', 'img.wpuf-clone-field', this.cloneField);
                }
               
                $('.wpuf-form').on('click', 'img.wpuf-remove-field', this.removeField);
                $('.wpuf-form').on('click', 'a.wpuf-delete-avatar', this.deleteAvatar);
                $('.wpuf-form').on('click', 'a#wpuf-post-draft', this.draftPost);
    
                $('.wpuf-form-add').on('submit', this.formSubmit);
                $('form#post').on('submit', this.adminPostSubmit);
    
                this.ajaxCategory();
                // image insert
                // this.insertImage();
            },
    #37431

    Nayem
    Moderator
    Post count: 6480

    Hello Rupert,

    Pelase open Wp user frotned/assets/js/frotned-form.js and find this function which named as “cloneField”. Please replace the function content with this one-

    cloneField: function( e ) {
                e.preventDefault();
    
                var $div = $(this).closest('tr');
                var $clone = $div.clone();
                var count = $div.closest('tbody').find('tr').length;
                if(count > 4){
                    return false;
                }
    
                //clear the inputs
                $clone.find('input').val('');
                $clone.find(':checked').attr('checked', '');
                $div.after($clone);
    },

    Thank you ๐Ÿ™‚

    #37473

    Rupert
    Member
    Post count: 2

    Hello Nayem,

    Fantastic. Perfect!!!!

    Thank you so much.

    Rupert

    #37493

    Nayem
    Moderator
    Post count: 6480

    Hello Rupert,

    You are welcome. I am marking this topic as resolved.

    Thank you ๐Ÿ™‚

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘How to make a repeater field only have 5 options’ is closed to new replies.