title: Drupal 7 Computed field
body: <p>I am learning Drupal 7 computed field. According to web sources they say i should use <code>$entity</code> instead of <code>$node</code> for Drupal 7.</p>
  
  <p>I have a content type product with custom fields field_price and field_discount. I need a computed field <code>field_finalprice = field_price - field_discount</code>.</p>
  
  <p>As a first step I am just trying to assign field_discount to my finalprice so I created a computed field with code </p>
  
  <pre><code>$entity_field[0]['value'] = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_discount')));
  </code></pre>
  
  <p>I do not get any value. Please provide any links that uses computed field for drupal 7.</p>