angular-form-builder icon indicating copy to clipboard operation
angular-form-builder copied to clipboard

Form elements ng-model dual binding

Open dinesh52 opened this issue 9 years ago • 5 comments

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

dinesh52 avatar Jan 11 '16 14:01 dinesh52

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

jagadeeshpalaniappan avatar Mar 19 '16 09:03 jagadeeshpalaniappan

$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

dinesh52 avatar Mar 21 '16 04:03 dinesh52

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?

jagadeeshpalaniappan avatar Mar 21 '16 19:03 jagadeeshpalaniappan

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

dinesh52 avatar Mar 22 '16 07:03 dinesh52

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
    });
   ...

delchev avatar Aug 05 '20 10:08 delchev