Hi everyone,
I have a DataObject called Product and it has a few fields:
<?php
class Product extends DataObject {
//db fields
static $db = array(
'Name' => 'Varchar',
'MotorType' => 'Enum("-- select --,Induction,Single stage","-- select --")',
'Measurement'=> 'Enum("-- select --,KiloWatt,Watt","-- select --")'
// etc
);
My question is how can I (dynamically) set the value for Measurement field based on what I set for MotorType.
Assuming this is my getCMSFields() function:
//Fields for the DOM Popup
public function getCMSFields(){
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Specifications', new DropdownField('MotorType', 'Motor Type',singleton('Product')->dbObject('MotorType')->enumValues()));
// ToDo: dynamic values for next field
}
If I choose "Induction" for MotorType, I want the Measurement field pick up the "KiloWatt" value automatically
and
If I choose "Single stage" for MotoType, the Measurement field should be set with "Watt" value (again dynamically).
Any thoughts?
Your help is much appreciated.
Soolan.