Hello,
I followed the doc to setup a money field on a model
-
Created amount (float) and currency_id (integer) in database table for that model
-
Added 'Initbiz.Money.Behaviors.MoneyFields' in behaviors
-
defined my money field in fields.yaml
price: label: 'price' type: money span: auto mode: amountcurrency
-
Added $moneyFields array
protected $moneyFields = [ 'price' => [ 'amountColumn' => 'amount', 'currencyIdColumn' => 'currency_id' ] ];
When I go to my model, I got the following error :
"Invalid argument supplied for foreach()" on line 25 of /plugins/initbiz/money/behaviors/MoneyFields.php
What did I miss ?
Last updated
Hello,
Thanks for using our plugin.
What do you mean by Added 'Initbiz.Money.Behaviors.MoneyFields' in behaviors
? You should implement the behavior in your model.
For example:
<?php namespace Initbiz\ExamplePlugin\Models;
use Model;
class ExampleModel extends Model
{
public $implement = [
'Initbiz.Money.Behaviors.MoneyFields'
];
...
}
As described in the docs: https://octobercms.com/docs/services/behaviors
Hello,
Thank you for your answer, this is what I did
Regards,
Alex
PS : I'm using SQLite, don't know if it could be related...
Last updated
Change protected $moneyFields
to public
. Should help.
I will fix the documentation as soon as possible :)
1-5 of 5