Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Patrick Robin 34 posts 104 karma points
    Oct 19, 2015 @ 13:55
    Patrick Robin
    0

    Custom tree help

    I'm extending the back office with a new section to hold custom form data. My controller code is as below and everything is working fine, however what I would like to do is once the save method has been called redirect the user to the edit page for the newly created form in the same manner as when creating a new macro. I'm assuming that this is done using the navigationService however I have no idea how to go about it. Anyone got any tips?

    angular.module("umbraco").controller("MyForm.MyFormCreateController",
    function ($scope, $routeParams, contactFormResource, notificationsService, navigationService) {
    
        $scope.loaded = true;
        $scope.form = {};
    
        $scope.save = function (form) {
            contactFormResource.save(form).then(function (response) {
                $scope.form = response.data;
                navigationService.syncTree({ tree: "contactForms", path: [-1, -1], forceReload: true });
                notificationsService.success("Success, the form ", form.Name + " has been saved");
            });
        };
    });
    
  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Oct 19, 2015 @ 14:36
    David Brendel
    0

    Hi Patrick,

    don't think you can use the navigationService for that.

    I change the window.location with the path to the edit page in a custom section I build.

    Regards David

  • Patrick Robin 34 posts 104 karma points
    Oct 19, 2015 @ 15:11
    Patrick Robin
    0

    Thanks for the quick reply David, I tried adding

    window.location("umbraco#/myForms/forms/edit/"+ form.id);
    

    at the end of the save function and whilst the url is changing in the address bar it doesn't actually load the content and raises an error about unsaved changes?

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Oct 19, 2015 @ 16:16
    David Brendel
    101

    Hi Patrick,

    think that is because your Form in the page is marked as $dirty from angular. This prevents umbraco from changing the view.

    Maybe you can check that?

    Regards David

  • Patrick Robin 34 posts 104 karma points
    Oct 19, 2015 @ 20:44
    Patrick Robin
    0

    Thanks for your help David, got me looking in the right direction. I ended up resetting the dirty flag on my form and then using

    $location.url("/myForms/forms/edit/"+ form.id);
    

    and its now all working as expected.

Please Sign in or register to post replies

Write your reply to:

Draft