I have issue about dependsOn function on 2 level. Please find following yaml file.
income_per_day:
label: Income Per Day
type: number
income_per_week:
label: Income Per Week
type: number
income_per_month:
label: Income Per Month
type: number
income_per_year:
label: Income Per Year
type: number
income_total:
label: Income Total
type: number
dependsOn:
- income_per_day
- income_per_week
- income_per_month
- income_per_year
pay_per_day:
label: Pay Per Day
type: number
pay_per_week:
label: Pay Per Week
type: number
pay_per_month:
label: Pay Per Month
type: number
pay_per_year:
label: Pay Per Year
type: number
pay_total:
label: Pay Total
type: number
dependsOn:
- pay_per_day
- pay_per_week
- pay_per_month
- pay_per_year
balance
label: Balance
type: number
dependsOn:
- pay_total
- income_total
- income_total depends on income_* works fine.
- pay_total depends on pay_* works fine.
- balance depends on pay_total works fine.
- balance depends on income_total works fine.
I would like to update balance value by income_per_day, income_per_week, income_per_month, income_total, pay_per_day, pay_per_week, pay_per_month and pay_per_year by pass pay_total and income_total. But I wouldn't to use following balance config.
"I would like to update balance value by income_per_day, income_per_week, income_per_month, income_total, pay_per_day, pay_per_week, pay_per_month and pay_per_year by pass pay_total and income_total. But I wouldn't to use following balance config."
"I would like to update balance value by income_per_day, income_per_week, income_per_month, income_total, pay_per_day, pay_per_week, pay_per_month and pay_per_year by pass pay_total and income_total. But I wouldn't to use following balance config."
Example:
If I update value on income_per_day.
it should to update value in income_total and effect to value in balance field in the same time.
Same with pay_per_day.
If I update value on pay_per_day.
it should to update value in pay_total and effect to value in balance field in the same time.
public function getFieldCAttribute()
{
return $this->field_a + $this->field_b;
}
public function getFieldTotalAttribute()
{
return $this->field_c * 2;
}
public function getFieldCAttribute()
{
return $this->field_a + $this->field_b;
}
public function getFieldTotalAttribute()
{
return $this->field_c * 2;
}
Hi mjauvin,
Thank you for you reply.
It works fine but need to reload page. May you have the way to calculate value with AJAX?
Ok, this is working fine but you cannot use the "_" in front of field names you want to dependOn... their value is not sent with the AJAX request.
Note: text/number fields need to lose focus in order for the dependent fields to be refreshed. Also, you don't need to add data-request=onAjax and data-track-input in order for this to work.