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

[Addon Request] Form Builder / Quiz Builder #3

Open
gvinson opened this issue Jun 24, 2020 · 4 comments
Open

[Addon Request] Form Builder / Quiz Builder #3

gvinson opened this issue Jun 24, 2020 · 4 comments
Assignees
Labels

Comments

@gvinson
Copy link

gvinson commented Jun 24, 2020

Feature Request

Ability to dynamically add fields to a CRUD view

What's the feature you think Backpack should have?

On the create/edit views, users would be able to dynamically add fields/sections to their form. They would be able to click a "Add" button that would let them select from a list of available form fields. After selecting one, the code would inject that field and all its required dependencies into the UI.

Have you already implemented a prototype solution, for your own project?

We have been working on it but since it uses the @push for scripts needed for each field, those JS scripts are not available when dynamically adding new fields. For example, if we started with a form that had a single input but wanted to add a CKEdtiro field, as of now, the ckeditor.js file/config will not have been loaded due to the way blade renders/uses stacks.

Do you see this as a core feature or an add-on?

I definitely see this as a core feature.

@welcome
Copy link

welcome bot commented Jun 24, 2020

Hello there! Thanks for opening your first issue on this repo!

Just a heads-up: Here at Backpack we use Github Issues only for tracking bugs. Talk about new features is also acceptable. This helps a lot in keeping our focus on improving Backpack. If you issue is not a bug/feature, please help us out by closing the issue yourself and posting in the appropriate medium (see below). If you're not sure where it fits, it's ok, a community member will probably reply to help you with that.

Backpack communication channels:

  • Bug Reports, Feature Requests - Github Issues (here);
  • Quick help (How do I do X) - Gitter Chatroom;
  • Long questions (I have done X and Y and it won't do Z wtf) - Stackoverflow, using the backpack-for-laravel tag;
  • Showing off something you've made, asking for opinion on Backpack/Laravel matters - Reddit;

Please keep in mind Backpack offers no official / paid support. Whatever help you receive here, on Gitter, Slack or Stackoverflow is thanks to our awesome awesome community members, who give up some of their time to help their peers. If you want to join our community, just start pitching in. We take pride in being a welcoming bunch.

Thank you!

--
Justin Case
The Backpack Robot

@pxpm
Copy link

pxpm commented Jun 26, 2020

Hum .. hello @gvinson thanks for the suggestion.

But pratically what would be the application ?

From my understanding of your issue I can see this beeing something along the inline create, atleast the implementation.

User clicks a button, an ajax request is made to get the available fields, user select the field and another ajax request is done to pick the field definition. This last gets you the field html (including the scripts and styles) you can then add it to the DOM.

About the request part, maybe create an Operation that setups the routes and handle the available fields and the return of html .

I saw one of this days someone talking about something similar, like having "pre forms" made, and when you select the type of the form you want you get a different form. Dunno if you are trying to achieve the same. It's is somewhere around here in github, but i cannot find the issue/pr now.

@spaznuski
Copy link

So I am working on a similar concept for a project I am converting from Codeigniter to Laravel using backpack. In the Codeigniter version I had a form which allowed the user to select an option from a select list (dropdown) and it would insert additional form fields in DOM.

The Laravel (Backpack) version is done by using a custom select2 form field copied from backpack and adding some jscript to insert the info into the DOM. e.g
$('#{{ $field['name'] }}').change(function() { var val = this.value; // value of the select element if (val != '') { $('#load_activity').load('{{ backpack_url('BACKPACK_CONTROLLER/ACTION') }}/' + val); } });

Now where I am stuck is I want to use another backpack field as the response from the call to action in the controller. So I copied and edited the table form field but I am still working out how to pass the required data so it can be loaded in the DOM.

So I want the function to be able to return the custom backpack form field view that can be inserted, not sure if that is possible.
my function so far looks like this.
echo view('vendor.backpack.crud.fields.custom_table')->render();

@tabacitu
Copy link
Member

tabacitu commented Jun 30, 2020

Hi guys,

This sounds cool - it really does, but I think it's out of scope for Backpack's core. It sounds to me like it'd make a really cool add-on though. So I'm going to move this issue to backpack/addons to talk this through.

Let me rephrase what you said, and in the process explain how I see it:

  • this would basically be a form builder; the admin would be able to create custom forms; right? and then show that form somewhere; another good name for it would probably be quiz; an example for it would be Google Forms;
  • responses can easily be stored as JSON in an extras column in the db;
  • inside the Form CRUD, for the Create operation, I see the user as having an interface to add new fields (as you mentioned @gvisnson ) but also REORDER those fields, or delete a field; this is what I see as a minimum - I'm not sure a select2 will cut it @spaznuski because it'll be a PAIN if you make a mistake to remove everything if you can't reorder it or remove fields;
  • the above isn't easy to do, but not terribly difficult either; it needs a little JS magic 😄
  • what I think will need more thinking is the UPDATE operation; because if you have answers for a form/quiz, you probably still want data integrity; do you allow the admin to Update a Form once it's saved? Food for thought;

Anyway, I'm happy to see this issue. It's something I've always thought would be A LOT easier to build using Backpack than with anything else. If any of you have thoughts or code on this please share, I think it's something that would be very cool to have.

Cheers!

PS. Also let me know if I've misunderstood the issue at hand - it happens sometimes, that's why I like to rephrase 😆

@tabacitu tabacitu transferred this issue from Laravel-Backpack/CRUD Jun 30, 2020
@tabacitu tabacitu changed the title [Feature Request] Ability to dynamically add fields to a CRUD view [Addon Request] Form Builder / Quiz Builder Jun 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants