正如标题所说,我正在使用插件中的设置模型从组件访问设置,但得到空白结果而不是当前存储在数据库中。这就是我正在做的事情。首先这是我的fields.yaml
文件定义:
fields:
sandbox_enabled:
label: Activar modo Sandbox?
type: checkbox
default: false
ppal_fee:
label: Cargo de PayPal
type: text
ppal_discount:
label: Descuento por transferencias
type: text
ppal_app_id_sandbox:
label: PayPal Sandbox App ID (*)
type: text
ppal_developer_account:
label: PayPal Developer Account Email Address (*)
type: text
ppal_api_username_sandbox:
label: PayPal Username API Credentials (Sandbox) (*)
type: text
ppal_api_password_sandbox:
label: PayPal Password API Credentials (Sandbox) (*)
type: text
ppal_api_signature_sandbox:
label: PayPal Signature API Credentials (Sandbox) (*)
type: text
ppal_rest_client_id_sandbox:
label: PayPal REST API Username Credentials (Sandbox) (*)
type: text
ppal_rest_client_secret_sandbox:
label: PayPal REST API Secret Credentials (Sandbox) (*)
type: text
二、alomicuba.recharge.settings
在DB记录值:
{
"sandbox_enabled":"1",
"ppal_fee":"0.029",
"ppal_discount":"0.30",
"ppal_app_id_sandbox":"",
"ppal_developer_account":"",
"ppal_api_username_sandbox":"",
"ppal_api_password_sandbox":"",
"ppal_api_signature_sandbox":"",
"ppal_rest_client_id_sandbox":"",
"ppal_rest_client_secret_sandbox":""
}
最后,我如何获取组件中的设置值:
public function onAmountChange()
{
// The user amount
$amount = post('amount');
if (empty($amount))
{
throw new \Exception(sprintf('Por favor introduzca un valor.'));
}
$toReload = $amount - ($amount * Settings::get('ppal_fee') - Settings::get('ppal_discount'));
$this->page["confirmation_text"] = $toReload;
}
但它不起作用,因为这两个值Settings::get('ppal_fee')
是Settings::get('ppal_discount')
空的,为什么?我做错了什么?