Commit 1a8d5199 authored by ram4nd's avatar ram4nd
Browse files

Improve the code.

parent c80c4d94
...@@ -21,7 +21,7 @@ function commerce_omniva_field_schema($field) { ...@@ -21,7 +21,7 @@ function commerce_omniva_field_schema($field) {
'type' => 'varchar', 'type' => 'varchar',
'length' => 10, 'length' => 10,
'not null' => FALSE, 'not null' => FALSE,
), ),
); );
$indexes = array( $indexes = array(
'zip' => array('zip'), 'zip' => array('zip'),
......
...@@ -121,7 +121,7 @@ function commerce_omniva_field_settings_form($field, $instance, $has_data) { ...@@ -121,7 +121,7 @@ function commerce_omniva_field_settings_form($field, $instance, $has_data) {
function commerce_omniva_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) { function commerce_omniva_field_validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {
foreach ($items as $delta => $item) { foreach ($items as $delta => $item) {
if (!empty($item['zip'])) { if (!empty($item['zip'])) {
if (! is_numeric($item['zip'])) { if (!is_numeric($item['zip'])) {
$errors[$field['field_name']][$langcode][$delta][] = array( $errors[$field['field_name']][$langcode][$delta][] = array(
'error' => 'commerce_omniva_invalid', 'error' => 'commerce_omniva_invalid',
'message' => t('You must select a location.'), 'message' => t('You must select a location.'),
...@@ -146,6 +146,7 @@ function commerce_omniva_field_is_empty($item, $field) { ...@@ -146,6 +146,7 @@ function commerce_omniva_field_is_empty($item, $field) {
* Implements hook_field_formatter_info(). * Implements hook_field_formatter_info().
* *
* I could define more that one display. * I could define more that one display.
*
* @see field_example_field_formatter_view() * @see field_example_field_formatter_view()
*/ */
function commerce_omniva_field_formatter_info() { function commerce_omniva_field_formatter_info() {
...@@ -172,9 +173,7 @@ function commerce_omniva_field_formatter_view($entity_type, $entity, $field, $in ...@@ -172,9 +173,7 @@ function commerce_omniva_field_formatter_view($entity_type, $entity, $field, $in
$element[$delta] = array( $element[$delta] = array(
'#type' => 'html_tag', '#type' => 'html_tag',
'#tag' => 'p', '#tag' => 'p',
'#value' => '#value' => '<label> ' . $t_name . ':</label> ' . $place[$item['zip']]['NAME'],
'<label> ' . $t_name . ':</label> ' .
$place[$item['zip']]['NAME'],
); );
} }
break; break;
...@@ -202,7 +201,6 @@ function commerce_omniva_field_widget_info() { ...@@ -202,7 +201,6 @@ function commerce_omniva_field_widget_info() {
* *
* hook_widget_form() is where Drupal tells us to create form elements for * hook_widget_form() is where Drupal tells us to create form elements for
* our field's widget. * our field's widget.
*
*/ */
function commerce_omniva_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) { function commerce_omniva_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
$value = isset($items[$delta]['zip']) ? $items[$delta]['zip'] : ''; $value = isset($items[$delta]['zip']) ? $items[$delta]['zip'] : '';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment