I'm creating a sports league site.

I want to have a variable behind the scenes containing the current league standing. In a content type 'result', upon saving, I first want a field (previous standing) to be populated with this variable, and then for the variable to be updated with the new standing. But I have no idea where to even begin with this!

  • have you set up any custom fields for your content type "result" yet? Sep 11, 2013 at 23:36
  • Yes, I've created the previous standing and current standing fields, but I'm unsure how to go about creating a variable and getting it to integrate with this content type. Sep 11, 2013 at 23:47
  • ok. can you clarify how will you get the current standing value? Is it something a user will enter in a form or is it generated by another module? can you give more details Sep 12, 2013 at 6:25
  • I thought I'd create the variable using the variable api and declare a default value to start out. It would be a standalone global variable for each competitor. When the result content is saved, the cmpetitors' current standings are loaded and saved besides their names, and their new standings calculated from the results - using a php math function. That was the plan - but getting a start is provng difficult! Sep 12, 2013 at 10:33
  • Writing that out, it just hit me that instead of using the variable api, I could just have use profile2, have a current standing field there and perhaps use a custom rules action to load and adjust the new values. But this seems like a lot of extra bulk for something so simple. I'd prefer to hook into the form for this content type instead if its possible. Sep 12, 2013 at 10:42

1 Answer 1


I believe your best bet is to create your own module, with a custom form hook and the form submit which will process your data and do all your calculations and save the new value. The form tutorials in the Form API Examples can give you a lot of good insight how to do this.

Your Answer

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

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