I am unable to create a filter in views using the money field I created. The currency can added as a filter but I get an error if I try and add the amount as a filter. "Content: Price (field_price) - amount"
It will add the amount as a field but not as a filter.
Any help appreciated.

Comments

markus_petrux’s picture

Status: Active » Postponed (maintainer needs more info)

Sorry, I cannot reproduce here. Works for me. Please, make sure you're running latest versions of CCK and Views. If the problem persists, then please describe exactly what you're doing, which error are you getting and when. Also if you're using other contrib extensions to views. You may wish to export your view and content type and attach them here as a .txt files.

markox’s picture

Thanks for your reply, I have created a fresh install of drupal on another server and installed just cck and views plus money modules. I have added a money field to the page content type and created one page and I am still getting the same error. It is a browser error when I try to add the amount as a filter: An error occurred at http://mkxdesign.co.uk/clients/drupal/admin/build/views/ajax/add-item/se....

This is the txt of the view:

$view = new view;
$view->name = 'search';
$view->description = 'search';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'node';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
'title' => array(
'id' => 'title',
'table' => 'node',
'field' => 'title',
),
'field_money_amount' => array(
'label' => 'Money',
'alter' => array(
'alter_text' => 0,
'text' => '',
'make_link' => 0,
'path' => '',
'alt' => '',
'prefix' => '',
'suffix' => '',
'help' => '',
'trim' => 0,
'max_length' => '',
'word_boundary' => 1,
'ellipsis' => 1,
'strip_tags' => 0,
'html' => 0,
),
'link_to_node' => 0,
'label_type' => 'widget',
'format' => 'default',
'multiple' => array(
'group' => TRUE,
'multiple_number' => '',
'multiple_from' => '',
'multiple_reversed' => FALSE,
),
'exclude' => 0,
'id' => 'field_money_amount',
'table' => 'node_data_field_money',
'field' => 'field_money_amount',
'relationship' => 'none',
),
));
$handler->override_option('access', array(
'type' => 'none',
));
$handler = $view->new_display('page', 'Page', 'page_1');
$handler->override_option('path', 'search');
$handler->override_option('menu', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
'name' => 'navigation',
));
$handler->override_option('tab_options', array(
'type' => 'none',
'title' => '',
'description' => '',
'weight' => 0,
));

And text of the content type:

$content['type'] = array (
'name' => 'Page',
'type' => 'page',
'description' => 'A page, similar in form to a story, is a simple method for creating and displaying information that rarely changes, such as an "About us" section of a website. By default, a page entry does not allow visitor comments and is not featured on the site\'s initial home page.',
'title_label' => 'Title',
'body_label' => 'Body',
'min_word_count' => '0',
'help' => '',
'node_options' =>
array (
'status' => true,
'promote' => false,
'sticky' => false,
'revision' => false,
),
'old_type' => 'page',
'orig_type' => 'page',
'module' => 'node',
'custom' => '1',
'modified' => '1',
'locked' => '0',
'comment' => 0,
'comment_default_mode' => 4,
'comment_default_order' => 1,
'comment_default_per_page' => 50,
'comment_controls' => 3,
'comment_anonymous' => 0,
'comment_subject_field' => 1,
'comment_preview' => 1,
'comment_form_location' => 0,
);
$content['fields'] = array (
0 =>
array (
'label' => 'Money',
'field_name' => 'field_money',
'type' => 'money',
'widget_type' => 'money_widget',
'change' => 'Change basic information',
'weight' => '-4',
'currency_select_mode' => 'name',
'currency_display_mode' => 'a|+|c',
'allowed_currencies' =>
array (
'GBP' => true,
'AFA' => false,
'ALL' => false,
'DZD' => false,
'ARS' => false,
'AWG' => false,
'AUD' => false,
'AZN' => false,
'BSD' => false,
'BHD' => false,
'BDT' => false,
'BBD' => false,
'BYR' => false,
'BZD' => false,
'BMD' => false,
'BTN' => false,
'BOB' => false,
'BAM' => false,
'BWP' => false,
'BRL' => false,
'BND' => false,
'BGN' => false,
'BIF' => false,
'KHR' => false,
'CAD' => false,
'CVE' => false,
'KYD' => false,
'XOF' => false,
'XAF' => false,
'CLP' => false,
'CNY' => false,
'COP' => false,
'KMF' => false,
'CRC' => false,
'HRK' => false,
'CUP' => false,
'CYP' => false,
'CZK' => false,
'DKK' => false,
'DJF' => false,
'DOP' => false,
'XCD' => false,
'EGP' => false,
'SVC' => false,
'ERN' => false,
'EEK' => false,
'ETB' => false,
'EUR' => false,
'FKP' => false,
'FJD' => false,
'GMD' => false,
'GHC' => false,
'GIP' => false,
'XAU' => false,
'GTQ' => false,
'GGP' => false,
'GNF' => false,
'GYD' => false,
'HTG' => false,
'HNL' => false,
'HKD' => false,
'HUF' => false,
'ISK' => false,
'INR' => false,
'IDR' => false,
'IRR' => false,
'IQD' => false,
'ILS' => false,
'JMD' => false,
'JPY' => false,
'JOD' => false,
'KZT' => false,
'KES' => false,
'KRW' => false,
'KWD' => false,
'KGS' => false,
'LAK' => false,
'LVL' => false,
'LBP' => false,
'LSL' => false,
'LRD' => false,
'LYD' => false,
'LTL' => false,
'MOP' => false,
'MKD' => false,
'MGA' => false,
'MWK' => false,
'MYR' => false,
'MVR' => false,
'MTL' => false,
'MRO' => false,
'MUR' => false,
'MXN' => false,
'MDL' => false,
'MNT' => false,
'MAD' => false,
'MZM' => false,
'MMK' => false,
'NAD' => false,
'NPR' => false,
'ANG' => false,
'NZD' => false,
'NIO' => false,
'NGN' => false,
'KPW' => false,
'NOK' => false,
'OMR' => false,
'XPF' => false,
'PKR' => false,
'XPD' => false,
'PAB' => false,
'PGK' => false,
'PYG' => false,
'PEN' => false,
'PHP' => false,
'XPT' => false,
'PLN' => false,
'QAR' => false,
'ROL' => false,
'RUB' => false,
'RWF' => false,
'WST' => false,
'STD' => false,
'SAR' => false,
'SCR' => false,
'RSD' => false,
'SLL' => false,
'XAG' => false,
'SGD' => false,
'SKK' => false,
'SBD' => false,
'SOS' => false,
'ZAR' => false,
'LKR' => false,
'SHP' => false,
'SDD' => false,
'SRD' => false,
'SZL' => false,
'SEK' => false,
'CHF' => false,
'SYP' => false,
'TWD' => false,
'TZS' => false,
'THB' => false,
'TOP' => false,
'TTD' => false,
'TND' => false,
'TRY' => false,
'USD' => false,
'AED' => false,
'UGX' => false,
'UAH' => false,
'UYU' => false,
'UZS' => false,
'VUV' => false,
'VEB' => false,
'VND' => false,
'YER' => false,
'YUM' => false,
'ZMK' => false,
'ZWD' => false,
),
'description' => '',
'default_value' =>
array (
0 =>
array (
'amount' => '',
'currency' => '',
'_error_element' => 'default_value_widget][field_money][0][amount',
),
),
'default_value_php' => '',
'default_value_widget' => NULL,
'required' => 1,
'multiple' => '0',
'precision' => '10',
'decimals' => '2',
'op' => 'Save field settings',
'module' => 'money',
'widget_module' => 'money',
'columns' =>
array (
'amount' =>
array (
'type' => 'numeric',
'precision' => '10',
'scale' => '2',
'not null' => false,
'sortable' => true,
'views' => true,
),
'currency' =>
array (
'type' => 'varchar',
'length' => 3,
'not null' => false,
'sortable' => true,
'views' => true,
),
),
'display_settings' =>
array (
'label' =>
array (
'format' => 'above',
'exclude' => 0,
),
'teaser' =>
array (
'format' => 'default',
'exclude' => 0,
),
'full' =>
array (
'format' => 'default',
'exclude' => 0,
),
4 =>
array (
'format' => 'default',
'exclude' => 0,
),
),
),
);
$content['extra'] = array (
'title' => '-5',
'body_field' => '-2',
'menu' => '-3',
);

markus_petrux’s picture

Thanks for the detailed information, but cannot see where the problem might be. Also tried the same configuration, and it works here.

I'm running latest development snapshots of CCK and Views though. Also, latest 6.x-2.x-dev snapshot of jquery_update, that comes with jQuery 1.3.2.

I'm afraid I won't be able to help until the problem is described in a way that can be reproduced.

markox’s picture

Thanks for your help, I tried using the latest dev versions of cck and views but still the same problem on both installations.

markus_petrux’s picture

Please, edit and remove the login information ASAP!

markus_petrux’s picture

I'm on the site, and I've been able to see the error, but I cannot see the cause. No idea if it is a problem with the server, or maybe the browser. It tried with IE6 and saw the error, but I was unable to try with Firefox3 as the site did not respond when trying to edit the view.

There's little I can do if I cannot reproduce this on my dev environment.

markus_petrux’s picture

hmm... IIRC, you were using version 6.x-1.1 of Money module. Please, try with latest 6.x-1.x-dev snapshot. I few days ago I fixed a PHP notice that could be the cause of your problem.

markox’s picture

I did try again with the latest 6.x-1.x-dev snapshot, still getting the same error.
Thanks for all your help Markus

markus_petrux’s picture

Marked the following issue as a duplicate: #452844: Adding 'money' type CCK field to filters causes error

Back to the issue, I was not able to reproduce the error on my development environment. So, I don't know what might be the cause :(

dejamuse’s picture

Thanks for noticing the duplicate issue entry I made on this - I had looked for an existing report but missed it.

I am running D6.11, Views 2.5, and Money CCK 1.1.

I have the same error from several different browsers on different OS platforms, so it's probably a Views issue. I noticed that after hitting the "add" button, the little JS circle does its thing for about one second before the error appears, if that means anything.

I don't know what else to do to help track this down. This is the first time I've tried using Views, so can't say if the Money CCK field ever worked in Views2. I don't see much point in me uploading the view or trying dev code since the originator of this issue already has.

Not using CVS and SVN here, so can't easily roll anything back. It would be nice if someone could verify that this field worked once before, at least.

...Jeff

markus_petrux’s picture

Views integration was introduced with Money CCK field 6.x-1.1, so it's hard to tell if this feature would have worked before for you both. :(

I'm also running D6.11, Views 2.5, but I'm running latest Money 6.x-1.x-dev and CCK 6.x-2.x-dev. Maybe the difference is here? If you upgrade, be sure to make backups and run update.php.

http://ftp.drupal.org/files/projects/money-6.x-1.x-dev.tar.gz
http://ftp.drupal.org/files/projects/cck-6.x-2.x-dev.tar.gz

Another thing that could be tried is trying to edit the view with javascript disabled. Maybe that shows something that's missing behind the scenes of all ajax in views ui. Besides checking any possible error visible during normal operation of the views ui, maybe there's something in the Drupal logs, apache logs, PHP logs?

It's hard to tell because it works for me here. And I cannot figure out where the problem may live.

dejamuse’s picture

I upgraded CCK to the dev version and the problem went away.

I did not upgrade Money, and the very first thing I did after creating a new test view was add the Money field filter.

markus_petrux’s picture

@dejamuse: Thanks for confirming. :)

I introduced Views support in Money module when CCK was ready to support fields with more than one column by itself. Here's the issue of the CCK queue: #131953: Expose additional database columns to Views (not just 'value')

But views integration in CCK has seen a few changes since CCK 2.2 was released. Maybe that is what was affecting you, dejamuse.

Glad it worked now.

@markox: Reviewing the release notes on Money 1.1, I now recall that you also need to install latest development version con Currency API.

Here's the issue in the Money queue: #217842: Format currencies according to their own custom, add hints for this to the Currency API

I also requested a new release of Currency API, but still waiting... here's the issue in the Currency queue: #329052: decimal count for currencies

I do not recall the version of currency you had installed, markox. Here's latest dev snapshots that need to be installed together:

http://ftp.drupal.org/files/projects/cck-6.x-2.x-dev.tar.gz
http://ftp.drupal.org/files/projects/currency-6.x-1.x-dev.tar.gz
http://ftp.drupal.org/files/projects/money-6.x-1.x-dev.tar.gz

Also, to discard it is not ajax related, please try adding the filter with javascript disabled.

markus_petrux’s picture

Status: Postponed (maintainer needs more info) » Fixed

Well, based on #12 and having no further feedback from original reporter, I'm going to assume the problem is fixed when all latest versions are properly installed.

Please, feel free to re-open with an explanation on how to reproduce the issue, if the problem persists. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.