Jump to:

23453 Posts in 18902 Topics by 2877 members

General Questions

SilverStripe Forums » General Questions » get CMS Fields Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 628 Views
  • voodoochile
    Avatar
    Community Member
    52 Posts

    get CMS Fields Questions Link to this post

    Hi All

    Just a couple of Questions not sure if what i'm trying to do can be done.

    I have a Dataobject and a list of fields for the CMS a number of the fields contain a number for weight i need to have each of these fields query another table for a price and then calculate the weight*price and hold the answer for further calculations.

    This is a small part of a rather long and complex formula that needs to return several parts.

    my main question at the moment is can i add a query to the addfieldtotab in the getCMSFields function or will i have to write a seperate function for each field and then call it, or am i better making this portion of the dataobject a seperate data object and writing a single function to do this?

    Although the last option may add complications to the rest of the formula.

  • swaiba
    Avatar
    Forum Moderator
    1788 Posts

    Re: get CMS Fields Questions Link to this post

    Dataobject and a list of fields for the CMS a number of the fields contain a number for weight i need to have each of these fields query another table for a price and then calculate the weight*price and hold the answer for further calculations

    This is a bit vague, but a suggestion might be to use the values in the onBeforeWrite to perform the calculation. you can add a literal field with the result int eh edit form that is shown only when this field has been calculated.

  • voodoochile
    Avatar
    Community Member
    52 Posts

    Re: get CMS Fields Questions Link to this post

    Hi Swaiba

    Thanks for the quick reply, I'm sorry if this was a bit vauge as i'm still getting some of it straight in my head.

    this is part of a project that produces a quote for the application of Fertiliser, each quote has a recipe for the mix this is where the weights come in to it. Each component has a weight value and a price for that component.

    At present i have the product and the price in a different table because they need to be updatable.

    i need to have each component come up with a cost by weight e.g 10kg * price per Kg.
    I am using this a start point because there are several other calculations involved as well.
    this project only uses the CMS there are no front end components, and the results will need to be updatable if the recipe is changed as it will be adjusted during the quote process.

    i think the queries will need to run each time the page is loaded because it will need to recalculate any changes, so the results will be stored in the session only? is this correct?

    really i'm just not sure as to where the best place is to place the queries and the best method to use to get the right result i think that once i get this part going i should be able to figure the rest out .

    Hope this Clears up what i'm trying to do

    628 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.