This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

xyz.qtc63355
xyz.qtc63355

Hello. I have two fields:

  1. Quantity
  2. Packages
quantity:
        label: Quantity
        span: auto
        dependsOn:
            - packages
        type: text
    packages:
        label: Packages
        span: auto
        dependsOn:
            - quantity
        type: text

When I input quantity, I need to update the number of packages (packages = quantity / items_in_a_package) When I input packages, I need to update the quantity of products (quantity = packages * items_in_a_package)

These two fields are dependent on each other, but the thing is that doesent work. Any idea?

public function filterFields($fields, $context = null)
    {
  if($fields->packages->value != "")
  {
       $fields->quantity->value = doubleval($fields->_package->value) * doubleval($fields->packages->value);
  }
if($fields->quantity->value != "")
{
   $fields->packages->value = doubleval($fields->quantity->value) / doubleval($fields->_package->value);
}
}

Last updated

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.