form.inc.php 1023 B

1234567891011121314151617181920
  1. function omnipotent($field, $value, $fieldinfo) {
  2. extract($fieldinfo);
  3. $formtext = str_replace('{FIELD_VALUE}',$value,$formtext);
  4. $formtext = str_replace('{MODELID}',$this->modelid,$formtext);
  5. preg_match_all('/{FUNC\((.*)\)}/',$formtext,$_match);
  6. foreach($_match[1] as $key=>$match_func) {
  7. $string = '';
  8. $params = explode('~~',$match_func);
  9. $user_func = $params[0];
  10. $string = $user_func($params[1]);
  11. $formtext = str_replace($_match[0][$key],$string,$formtext);
  12. }
  13. $id = $this->id ? $this->id : 0;
  14. $formtext = str_replace('{ID}',$id,$formtext);
  15. $errortips = $this->fields[$field]['errortips'];
  16. if($errortips) $this->formValidator .= '$("#'.$field.'").formValidator({onshow:"",onfocus:"'.$errortips.'"}).inputValidator({min:'.$minlength.',max:'.$maxlength.',onerror:"'.$errortips.'"});';
  17. if($errortips) $this->formValidator .= '$("#'.$field.'").formValidator({onshow:"'.$errortips.'",onfocus:"'.$errortips.'"}).inputValidator({min:1,onerror:"'.$errortips.'"});';
  18. return $formtext;
  19. }