Computed Field - only save value on inser and not update

mattyb - March 10, 2008 - 14:04

Hi

I'm using the compute field to generate an api key, only I don't want it to re-run the script every time I save the page, only on insert.

I'm not sure what approach I should take.

Thanks in advance

Matt

Me too!

jaxta - March 11, 2008 - 09:14

I could really do with some help on this as well (for slightly different reasons!).

Can anyone help?

thx

Sorted

mattyb - March 11, 2008 - 09:38

To get the computed field to only generate first time around is a simple as wrapping this around your computed code

if ($node_field[0]['value'] == '' )
{ $node_field[0]['value'] = "hello" ; /* only work on insert and not on upates */ }

Thanks to jaxta who helped on this

Matt
www.crawlscore.com

 
 

Drupal is a registered trademark of Dries Buytaert.