<?
class MLookupTextField extends MLookupField
{
    public $autocomplete;
    
    public function __construct($name='',$value='',$label='', 
                 $size=10,$hint='',$validator=null,$related='',
	             $module='',$item='', $event='filler', $filter='', $autocomplete=false)
    {   
        parent::__construct($name,$value,$label,$hint,$related, $module, $item, $event, $filter); //$validator);
        $this->size = $size;
        $this->filter = $filter ? $filter : $this->name;
        $this->autocomplete = $autocomplete ? true : false;
        $this->validator = is_string($validator) ? MValidator::MASKValidator($validator) : $validator;
        $this->showLabel = false;
    }

    public function getAutocompleteData()
    {
        $autocomplete = new MAutoComplete($this->module,$this->item,$this->value,$this->related);
        $info = $autocomplete->getResult();
        return $info;
    }
    
   public function generateInner()
   {
        $field = new MTextField($this->name,$this->value,$this->label,$this->size,$this->hint, $this->validator);
        $field->attrs = $this->attrs;
        if ( $this->autocomplete )
        {
            $field->addEvent('change',"{$this->lookup_name}.start();");
        }
        $field->validator = $this->validator;
        $field->form      = $this->form;
      
        $field->setClass('mTextField'); 
        $field->showLabel = $this->showLabel;
        $field->formMode = $this->formMode;
	    if ( $this->readonly )
        {
            $field->setClass('mReadOnly');
            $field->addAttribute('readonly');
        }

//      $html = $field->generate();
        $div = new MDiv('', $field );

        parent::generateInner();
        $lookupField = $this->getInner();
        $c = new MHContainer('', array($field, ( $this->readonly  ? '' : $lookupField)));
        $c->setClass('mLookupField');
        $c->setShowChildLabel( false, true );
        $this->inner = $c;
   }

}

?>
