Changeset 5390
- Timestamp:
- 02/19/07 14:40:45 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/midcom.helper.datamanager2/formmanager.php
r5372 r5390 164 164 } 165 165 166 function _load_type_qfrules($fieldname) 167 { 168 $config = $this->_schema->fields[$fieldname]; 169 $filename = MIDCOM_ROOT . "/midcom/helper/datamanager2/QuickForm_rules/{$config['type']}.php"; 170 $classname = "midcom_helper_datamanager2_qfrule_{$config['type']}_manager"; 171 if (class_exists($classname)) 172 { 173 // We have already initialized rules for this type 174 return; 175 } 176 if (!file_exists($filename)) 177 { 178 // no file for this type found, skip silently 179 return; 180 } 181 include_once($filename); 182 $manager = new $classname(); 183 $manager->register_rules($this->form); 184 } 185 166 186 /** 167 187 * This function fully initializes the class for operation. This is not done during the … … 487 507 function _add_rules_and_filters($name, $config) 488 508 { 509 $this->_load_type_qfrules($name); 489 510 $widget =& $this->widgets[$name]; 490 511 if ($config['readonly']) … … 529 550 && !is_a($type, 'midcom_helper_datamanager2_type_images')): 530 551 // 'required' does not work for uploads -> use 'uploadedfile' 552 // OTOH: Does this mean it requires new upload each time ?? TODO: Test 531 553 $this->form->addRule($name, $message, 'uploadedfile', ''); 532 554 break; 533 555 // Match all other blobs types (those allow multiple uploads which are kind of hard to validate) 534 556 case (is_a($type, 'midcom_helper_datamanager2_type_blobs')): 535 // How will you require-validate N uploads ??557 // PONDER: How will you require-validate N uploads ?? (also see the point about existing files above) 536 558 debug_push_class(__CLASS__, __FUNCTION__); 537 559 debug_add("types with multiple files cannot have required validation (field name: {$name})", MIDCOM_LOG_ERROR); … … 539 561 break; 540 562 // Match select types (have array data, 'required' will choke on them) 541 case (is_a($type, 'midcom_helper_datamanager2_type_select')): 542 // TODO: register callback 543 debug_push_class(__CLASS__, __FUNCTION__); 544 debug_add("select types cannot have required validation ATM (field name: {$name})", MIDCOM_LOG_INFO); 545 debug_pop(); 563 case ( is_a($type, 'midcom_helper_datamanager2_type_select') 564 && $type->allow_multiple): 565 debug_add("Callign this->form->addRule('{$name}', '{$message}', 'requiremultiselect', '');"); 566 $stat = $this->form->addRule($name, $message, 'requiremultiselect', ''); 567 if (is_a($stat, 'pear_error')) 568 { 569 $msg = $stat->getMessage(); 570 debug_push_class(__CLASS__, __FUNCTION__); 571 debug_add("Got PEAR error '{$msg}' from this->form->addRule('{$name}', '{$message}', 'required_multiselect', ''), when adding multiselect required rule", MIDCOM_LOG_WARN); 572 debug_pop(); 573 } 546 574 break; 547 575 // Other types should be fine with the default string validation offered by 'required' … … 672 700 { 673 701 // Validate the from. 702 debug_push_class(__CLASS__, __FUNCTION__); 703 debug_print_r('this->form', $this->form); 704 debug_print_r("\$GLOBALS['_HTML_QuickForm_registered_rules']", $GLOBALS['_HTML_QuickForm_registered_rules']); 705 debug_pop(); 674 706 if (! $this->form->validate()) 675 707 {
