Add ability to edit forms and add new fields
This commit adds the ability to edit and modify existing forms. On the technical side, it also adds a new reusable validation Facade which helps reduce duplicated code.
This commit is contained in:
1
public/js/formbuilder.js
vendored
1
public/js/formbuilder.js
vendored
@@ -1,3 +1,4 @@
|
||||
// TODO: Add cleaner and less verbose solution found in formeditor.js
|
||||
$(document).ready(function() {
|
||||
$("#add").click(function() {
|
||||
var lastField = $("#buildyourform div:last");
|
||||
|
19
public/js/formeditor.js
vendored
Normal file
19
public/js/formeditor.js
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// reminder: use vuejs instead, this is still an ugly and cheap solution
|
||||
$(document).ready(function(){
|
||||
|
||||
var fieldID = 0;
|
||||
var wrapper = $('.field-container');
|
||||
var newBtn = $('#add');
|
||||
|
||||
$(newBtn).click(function(e){
|
||||
e.preventDefault()
|
||||
fieldID++;
|
||||
|
||||
$(wrapper).append('<div id=group' + fieldID + '><input type="text" name="newFieldID' + fieldID + '[]" class="form-control" />');
|
||||
$(wrapper).append('<select name="newFieldID' + fieldID + '[]" class="custom-select"> <option value="nil" disabled>Choose a type</option> <option value="textbox">Textbox</option> <option value="textarea">Multi line answer</option> <option value="checkbox">Checkbox</option> </select>');
|
||||
//$(wrapper).append('<button type="button" class="btn btn-danger btn-sm float-right delete"><i class="fas fa-minus"></i></button></div>');
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user