Skip to content

Instantly share code, notes, and snippets.

@rfsbsb
Created August 21, 2012 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rfsbsb/3419279 to your computer and use it in GitHub Desktop.
Save rfsbsb/3419279 to your computer and use it in GitHub Desktop.
Campo de preço por metro quadrado computado no Drupal
<?php
$area = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_area')));
$preco = array_pop(array_pop(field_get_items($entity_type, $entity, 'field_preco')));
if ($preco > 0) {
$entity_field[0]['value'] = number_format(($preco / $area), 2, ',', '.');
} else {
$entity_field[0]['value'] = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment