Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

having multiple inputs (text fields) on a line #1

Open
olee2002 opened this issue May 7, 2019 · 2 comments
Open

having multiple inputs (text fields) on a line #1

olee2002 opened this issue May 7, 2019 · 2 comments

Comments

@olee2002
Copy link

olee2002 commented May 7, 2019

First of all, thanks for the great package! I just started working on a project that uses the Laravel MVC that successfully incorporated your form-builder package. I am new to Laravel and to this form-builder. We have noticed that the current form-builder is only allowing one textfield in a line. Is there any way we could customize this to have multiple textfield in a line? For example, could we have a functionality to add a div wrapper? I would really appreciate if you could give any clues or directions.

@olee2002 olee2002 changed the title having multiple input (textField in one line) having multiple inputs (text fields) one line May 7, 2019
@olee2002 olee2002 changed the title having multiple inputs (text fields) one line having multiple inputs (text fields) on a line May 7, 2019
@olee2002
Copy link
Author

olee2002 commented May 9, 2019

I found something that helped me and might also be beneficial to others although it is not a perfect solution.
See the code below, after hours of looking around in Jquery form-builder and their jitter site. I found some code that was just enough for me to go forward at this point. The code below can be added to the preview and render views and passed into the render options ( For my case, her render function was under public/vendor/formbuilder/js/preview-form.js or render-form.js.

I had to spend too many hours just to figure this part out so hopefully, this can save someone else' valuable time so the world can be a better place!.. just kidding.

	var fbRenderOptions = {
		container: false,
		dataType: 'json',
		formData: window._form_builder_content ? window._form_builder_content : '',
      render: true,
      notify: {
         success: function(message) {
             // This looks for all elements having a class named something like
             // "_col3" "_col6" and then adds the parent wrapper the bootstrap class
             var cols = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
             $('.rendered-form > div').each(function(){
                 var parent = $(this);
                 var foundFlag = false;
                 for (var n in cols){
                     var col = cols[n];
                     $('._col'+col, parent).each(function(){
                         foundFlag = true;
                         var el = $(this);
                         var className = 'col-sm-'+col;
                         if (!parent.hasClass(className)){
                             parent.addClass(className)
                             //this sets flex-row so the fields can be side by side in a line.
                             parent.parent().addClass('row')
                         }
                     });
                 }
                 if (foundFlag === false){
                     var className = 'col-sm-12';
                     if (!parent.hasClass(className)){
                         parent.addClass(className)
                     }
                 }
             });
         }
     }
   }

   $('#fb-render').formRender(fbRenderOptions)

})```

@Sogl
Copy link

Sogl commented Jun 17, 2019

@olee2002 You can add a PR so the world can be a better place 😉 🌎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants