angular-drupal icon indicating copy to clipboard operation
angular-drupal copied to clipboard

How to get success message

Open fufu7755 opened this issue 9 years ago • 6 comments

Very good tools! When I update user or node how to get success message and error message.I saw jDruapl api there are success message, but I could not read it. Please give me a help!

Thank you!

fufu7755 avatar Oct 27 '16 03:10 fufu7755

@fufu7755 Drupal 7 or 8?

signalpoint avatar Oct 27 '16 13:10 signalpoint

Thank you for your reply, I use drupal 7. Drupal 8 api seems to be small.

fufu7755 avatar Oct 27 '16 14:10 fufu7755

@fufu7755 jDrupal doesn't actually display the form success and/or errors either. DrupalGap has a little code snippet that tries to extract the form errors from the responseText during user login and registration: https://github.com/signalpoint/DrupalGap/blob/7.x-1.x/src/modules/user/user.js#L219

You can use that snippet to extract form errors from most resources (I think). As for success messages, no. You'll want your own success handlers to display messages for your application, because AFAIK we can't retrieve the success messages from Drupal, only error messages since they are delivered in the result.

signalpoint avatar Oct 27 '16 14:10 signalpoint

Thank you very much!
I still have a question. Now drupal 8 api less than drupal7, you will continue to improve drupal8? If I use drupal8 whether or not I can get sucess message? Thank you again!

fufu7755 avatar Oct 27 '16 14:10 fufu7755

@fufu7755 I won't be building any success message into D7 or D8, as I personally feel it is up to the application to decide what success message is displayed. However, it is possible right now to do this in D7 (and probably D8). In D7, you could theoretically use hook_services_request_postprocess_alter() from http://cgit.drupalcode.org/services/tree/docs/services.alter.api.php?h=7.x-3.x to use drupal_get_messagesand append those results to the JSON being delivered to your app, then your app could just iterate over those messages and display them as needed.

signalpoint avatar Oct 27 '16 14:10 signalpoint

@signalpoint Thank you for your help, I hope you can drupal 8‘s angular-drupal better. Thanks again!

fufu7755 avatar Oct 27 '16 14:10 fufu7755