kelp404 / angular-form-builder

Drag and drop to build bootstrap forms in AngularJS.
http://kelp404.github.io/angular-form-builder/
MIT License
599 stars 340 forks source link

Form elements ng-model dual binding #91

Open dinesh52 opened 8 years ago

dinesh52 commented 8 years ago

I have saved the form ng-model and if i want to edit the form again, all fields are empty, but $scope.input has the data.

Please help. Dinesh

jagadeeshpalaniappan commented 8 years ago

@dinesh52 Did u fix that?? Even i wanted to show the saved the form.. Could u pls help.

dinesh52 commented 8 years ago

$scope.defaultValue = {}; if (val.label == v.label) { val['value'] = v.value; $builder.addFormObject('default', val); if (val.hasOwnProperty('value')) { $scope.defaultValue[val.id] = val.value; } } else { $builder.addFormObject('default', val); }

I made this working in this way, val is coming from angularforloop of varaible which has form data

jagadeeshpalaniappan commented 8 years ago

Thank you very much @dinesh52

In my case, when i drag-and-drop elements, theid is null (nothing defined) in element object.

http://kelp404.github.io/angular-form-builder/

  1. Drag and Drop Textbox
  2. Check the Scope //the element will not have any id //how will we populate the default value?
dinesh52 commented 8 years ago

For that reason only we are assigning id val in defaultvalue to replace it $scope.defaultValue[val.id] = val.value;

delchev commented 3 years ago

ensure that when using $builder.insertFormObject(... you also generate the "id", e.g.:

    ...
    $builder.insertFormObject(scope.formName, $(element).find('.empty').index('.fb-form-object-editable'), {
        id: Math.random().toString(36).slice(2),
        component: draggable.object.componentName
    });
   ...