Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Difference between Save.php and function save()?

  1. #1
    ConFliX is offline Senior Member
    Join Date
    Aug 2009
    Posts
    25

    Smile Difference between Save.php and function save()?

    Hi everyone,

    I'm a Sugar newb and I'm trying to create my own EditView. I started out by using Module builder to build a basic "Person" module. From there I would like to modify things by hand (adding custom fields, etc).

    I've created the EditView.html and Editview.php and added the appropriate XTemplate assignments in order for information to be displayed when you click on "Edit" from an existing "person". This works great.

    My confusion lies in where information gets stored to the db. In referring to the "SugarCRM Developer's Manual" it mentions that you must define a new file called Save.php. Looking at this code it appears as though some preprocessing occurs and the data is written to the appropriate table (that has been defined in the Vardefs.php file). I wrote out the code from the book and I'm not sure if it's getting executed or not (not sure if I have to call something else).

    I've also looked through: http://www.sugarcrm.com/wiki/index.php?title=EditView , which hasn't helped me much because I'm not sure how the data is saved, I see that the save button contains a call to this: onclick="this.form.action.value='Save';return check_form('EditView');"

    On some other forum threads (http://www.sugarcrm.com/forums/showthread.php?t=40550) it says that you can use a "function save()" method in your class, which I would assume would get called with something like $focus->save().

    How/when are each of these things ( Save.php or save() ) called? Is Save.php still a relevant way to save data or should I be using something else entirely? I've tried to refer to other default modules (ex. Users, Email) but I think I've just confused myself further. Please help!

    Btw, I'm using SugarCRM CE 5.2.0h

    Any help would be greatly appreciated.

    Thanks in advance!

    Brian

  2. #2
    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: Difference between Save.php and function save()?

    Hi Brian

    Save.php is the script called when clicking on Save button.
    function save is the final function called when a records needs to be saved.
    The work flow: Save.php -> <Module>FormBase.php -> <Class>.php -> save function.

    Cheers
    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.

  3. #3
    ConFliX is offline Senior Member
    Join Date
    Aug 2009
    Posts
    25

    Default Re: Difference between Save.php and function save()?

    Hi André,

    Thank you for the quick response! So the actual insert/update occurs in the Save.php (if the code resides in there)? Is there a way to make sure that Save.php is getting called? It seems as though the page is redirected to the DetailView.php right after hitting save. Is there anything else that I have to modify in the corresponding vardefs.php file(add the default fields that currently exist in the table?).

    Thanks again for the info!

    Brian

  4. #4
    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: Difference between Save.php and function save()?

    Hi Brian

    Some built in modules has the Save.php script, what is a kind of archaeological code.
    The modules created by Module Builder has no the Save.php script, so the save logic is defined into SugarBean->save() function, but you can set some alternative rules through logic_hook before_save and after_save, and also through function action_save on controller.php, depending on your needs.

    There is not reason to create the EditView.html and EditView.php once these scripts are only required on developing modules by hand on 4.x versions.

    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.

  5. #5
    ConFliX is offline Senior Member
    Join Date
    Aug 2009
    Posts
    25

    Smile Re: Difference between Save.php and function save()?

    Hi André,

    Ok, I will look into using the SugarBean->save function then. Any good threads or tutorials you can think of that may help explain the use of the save function better? Or should I just refer to existing save functions in some of the default modules?

    Also, I have tried using the module builder to customize the EditView pages but the builder isn't allowing me the freedom to lay out the page as I want to. This is why I'm creating my own EditView, unless you have another thought of how to do this more easily?

    The book I'm using seems to be a little outdated when it comes to some stuff, which is understandable as sugar development is an ongoing process.

    Thanks for your remarks. I appreciate this!

    Brian

  6. #6
    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: Difference between Save.php and function save()?

    Hi Brian

    You may take a look at the Developer Guide.

    Alternatively lets us know your detailed needs and we may guide you better.
    You told you are not able to configure the layout you want.
    Can you kindly provide us a mock up of such layout?

    Best 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.

  7. #7
    ConFliX is offline Senior Member
    Join Date
    Aug 2009
    Posts
    25

    Default Re: Difference between Save.php and function save()?

    Hi André,

    ok thanks. I would like to create a table with 3 or 4 columns. I don't believe this is possible using the module builder. I also need to insert data into two tables.

    Brian

  8. #8
    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: Difference between Save.php and function save()?

    Hi Brian

    Which tables you want insert data?
    What kind of data are you going to insert into them?
    The four columns table you want to create is the detail view and edit view?

    Cheers
    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.

  9. #9
    ConFliX is offline Senior Member
    Join Date
    Aug 2009
    Posts
    25

    Default Re: Difference between Save.php and function save()?

    Hi André,

    I am creating a custom table that is used to store additional information other than what is already captured for a "Person" type module. Mostly text, some currency, checkboxes and percentages.

    I would like those 4 columns to exist in both the EditView and DetailView because I'm trying to mimic the current layout of a document that people are already accustomed to using.

    I'm currently reading through some of the Developers Manual (and some other threads) and it's starting to answer some of my questions as to what the most up-to-date developer paradigms are and what the most effective way of doing particular things is.

    Thanks again,

    Brian

  10. #10
    ConFliX is offline Senior Member
    Join Date
    Aug 2009
    Posts
    25

    Default Re: Difference between Save.php and function save()?

    Also, I'm reading about modifying the modules/[Module]/metadata/editviewdefs.php and I was wondering if any changes to these files are upgrade safe? Is there a way to override this file (similar to the en_us.lang.override.php functionality)?

    Brian

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Enhanced Studio - Logic Hook - Save function
    By mailfrd in forum Developer Help
    Replies: 0
    Last Post: 2009-07-08, 09:45 PM
  2. Replies: 2
    Last Post: 2007-09-19, 05:28 PM
  3. HELP! How to customize save function
    By fedepia in forum Help
    Replies: 4
    Last Post: 2007-09-19, 09:22 AM
  4. HowTo brake sugar save function?
    By fedepia in forum Developer Help
    Replies: 2
    Last Post: 2007-09-18, 03:24 PM
  5. export function in Accounts save button
    By daska in forum Developer Help
    Replies: 2
    Last Post: 2006-07-14, 07:47 AM

Tags for this Thread

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
  •