00001 <?php 00002 00003 class MFormControl extends MControl 00004 { 00005 public $label; 00006 public $value; 00007 public $hint; 00008 public $form; 00009 public $formName; 00010 public $showLabel; // se label deve ser exibido junto com o campo 00011 public $autoPostBack; 00012 00013 public function __construct( $name, $value = '', $label = '', $color = '', $hint = '' ) 00014 { 00015 parent::__construct( $name ); 00016 00017 $this->addStyleFile( 'm_controls.css' ); 00018 $this->setValue($value); 00019 $this->label = $label; 00020 $this->hint = $hint; 00021 00022 if ( $color != '' ) 00023 { 00024 $this->color = $color; 00025 } 00026 00027 $this->showLabel = true; 00028 $this->autoPostBack = false; 00029 $this->form = NULL; 00030 } 00031 00032 00033 public function setValue( $value ) 00034 { 00035 $this->value = $value; 00036 } 00037 00038 00039 public function getValue() 00040 { 00041 return $this->value; 00042 } 00043 00044 00045 public function setLabel( $label ) 00046 { 00047 $this->label = $label; 00048 } 00049 00050 00051 public function setAutoPostBack( $value ) 00052 { 00053 $this->autoPostBack = $value; 00054 } 00055 00056 function setAutoSubmit( $isAuto = true ) 00057 { 00058 $this->autoPostBack = $isAuto; 00059 } 00060 00061 public function generateLabel() 00062 { 00063 $label = ''; 00064 $this->showLabel = ( $this->formMode >= MControl::FORM_MODE_SHOW_ABOVE ); 00065 00066 if ( ( $this->showLabel ) && ( $this->label != '' ) ) 00067 { 00068 $span = new Span( '', $this->label, 'm-caption' ); 00069 00070 if( ! $this->validator && method_exists($this->form,'getFieldValidator') ) 00071 { 00072 $this->validator = $this->form->getFieldValidator($this->name); 00073 } 00074 00075 //if($this->name == 'zipCode') 00076 // vaR_dump($this->validator->type,get_class($this)); 00077 00078 $r = $this->attrs->items['required'] || ($this->validator && $this->validator->type == 'required'); 00079 00080 if( $r && trim(MUtil::removeSpaceChars($this->label)) ) 00081 { 00082 $span->setClass('m-caption-required'); 00083 } 00084 00085 $label = $this->painter->span( $span ); 00086 00087 if ( $this->formMode == MControl::FORM_MODE_SHOW_ABOVE ) 00088 { 00089 $label .= $this->painter->BR; 00090 } 00091 elseif ( $this->formMode == MControl::FORM_MODE_SHOW_NBSP ) 00092 { 00093 $label .= " "; 00094 } 00095 } 00096 return $label; 00097 } 00098 00099 } 00100 ?>