Results 1 to 3 of 3

Thread: Question regarding before_save logic hook

  1. #1
    edanb is offline Senior Member
    Join Date
    Dec 2008
    Posts
    25

    Default Question regarding before_save logic hook

    Using the before_save logic hook, how can I stop the save from taking place and return an error message to the user instead? For example if there is invalid data. (I prefer to do this server side and not using javascript).

    Thanks for the help!

  2. #2
    mvngti is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    South Africa
    Posts
    510

    Default Re: Question regarding before_save logic hook

    You can not "cancel" the save but you can die inside your logic hook.
    It's ugly but your logic hook could print an error and then call sugar_die()
    or redirect using php header() function and then die.

  3. #3
    andopes's Avatar
    andopes is offline A Sugar Hero | Help Forum Moderator
    Join Date
    Jul 2006
    Location
    São Paulo - Brazil
    Posts
    8,335

    Default Re: Question regarding before_save logic hook

    Hi edanb

    You can add a

    PHP Code:
    header("Location: new_address"); 
    Into your logic_hook function.

    Regards
    André Lopes
    DevToolKit / Project of the Month - June 2009
    Lampada Global Services- Open Source Solutions
    Avenida Ipiranga, 318
    Bloco B - CJ 1602
    São Paulo, SP 01046-010
    Brazil
    Office: +55 11 3237-3110
    Mobile: +55 11 7636-5859
    e-mail: andre@lampadaglobal.com

    Lampada Global delivers offshore software development and support services to customers around the world.
    Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.

    I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Logic Hook Question for Login
    By swhitlow in forum Developer Help
    Replies: 5
    Last Post: 2008-11-18, 02:50 PM
  2. Can I do this with a logic hook?
    By daerid in forum Developer Help
    Replies: 2
    Last Post: 2008-04-23, 05:49 PM
  3. Logic Hook
    By sacramentojoe in forum Help
    Replies: 15
    Last Post: 2007-07-31, 11:30 PM
  4. Logic Hook Question
    By dalty52 in forum Developer Help
    Replies: 3
    Last Post: 2007-04-30, 02:07 AM
  5. Logic Hook Question
    By swhitlow in forum Developer Help
    Replies: 1
    Last Post: 2006-06-04, 04:49 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •