0

I am trying to update record by angular post, below is code:

 $.post(url, data, function (result) {
                var error = false;
                if (result.success == 1 && (result.entry_id) != false) {
                    //alert('Saved Successfully!!')
                } else {
                    error = true;
                }
                $scope.$apply(function () {
                    $scope.loading = false;
                    if (error) {
                        $scope.error = true;
                        $scope.ErrorMessage = 'Internal server error occured.';
                    } else {
                        $scope.success = true;
                        window.location.href = "#/trVenueDetail/" + result.entry_id
                    }
                });

            });

But it's always made the new entry. Page URL is some thing like below:

http://example.com/new#/trAddVenue/47452

47452 is entry_id, I have tried to set it in hidden field:

The entry_id hidden field is automatically created by form tag.

  {exp:channel:form channel="venues" include_jquery="no" json="yes"
id="addVenu" name="addVenu" }

     -- Controls Html Is Here---

  {/exp:channel:form}

The Same code is working in case of add new record, but how to update existing.

And yes I am able to populate the value.

1 Answer 1

0

So I have found the answer by myself, in case of update we have to set the require_entry="yes" and need to pass the entry_id.

 {exp:channel:form channel="venues" entry_id="{segment_3}" require_entry="yes" include_jquery="no" json="yes" id="addVenu" name="addVenu" }

       -- Controls Html Is Here---

  {/exp:channel:form}

It will force to update rather then the new entry.

I hope this will help someone else.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.