Index: trunk/core/kernel/kbase.php =================================================================== diff -u -r3282 -r3307 --- trunk/core/kernel/kbase.php (.../kbase.php) (revision 3282) +++ trunk/core/kernel/kbase.php (.../kbase.php) (revision 3307) @@ -304,11 +304,23 @@ { $this->setTableName( $this->Application->getUnitOption($this->Prefix, 'TableName') ); $this->setIDField( $this->Application->getUnitOption($this->Prefix, 'IDField') ); + + $this->defineFields(); + + $this->ApplyFieldModifiers(); // should be called only after all fields definitions been set + $this->prepareConfigOptions(); // this should go last, but before setDefaultValues, order is significant! + $this->SetDefaultValues(); + } + + /** + * Add field definitions from all possible sources (DB Fields, Virtual Fields, Calcualted Fields, e.t.c.) + * + */ + function defineFields() + { $this->setConfigFields( $this->Application->getUnitOption($this->Prefix, 'Fields') ); $this->setVirtualFields( $this->Application->getUnitOption($this->Prefix, 'VirtualFields') ); $this->setCalculatedFields( $this->Application->getUnitOption($this->Prefix, 'CalculatedFields') ); - $this->prepareConfigOptions(); // this should go last, but before setDefaultValues, order is significant! - $this->SetDefaultValues(); } function setCalculatedFields($fields) @@ -325,10 +337,38 @@ */ function setConfigFields($fields) { - $this->Fields=$fields; + $this->Fields = $fields; } /** + * Override field options with ones defined in submit via "field_modfiers" array (common for all prefixes) + * + * @access private + * @author Alex + */ + function ApplyFieldModifiers() + { +// $this->Application->APCalled[] = $this->getPrefixSpecial(); + + $allowed_modifiers = Array('required'); + + $field_modifiers = $this->Application->GetVar('field_modifiers'); + if(!$field_modifiers) return false; + + $field_modifiers = getArrayValue($field_modifiers, $this->getPrefixSpecial()); + if(!$field_modifiers) return false; + + foreach ($field_modifiers as $field => $field_options) + { + foreach ($field_options as $option_name => $option_value) + { + if ( !in_array(strtolower($option_name), $allowed_modifiers) ) continue; + $this->Fields[$field][$option_name] = $option_value; + } + } + } + + /** * Set fields (+options) for fields that physically doesn't exist in database * * @param Array $fields