Exemplo n.º 1
0
 /**
  * Run this widget.
  * This method registers necessary javascript and renders the needed HTML code.
  */
 public function run()
 {
     // set search callback
     $this->options['search'] = "js:function() {\n      if ( this.value.length < {$this->minLength} ) {\n        return false;\n      }\n    }";
     // show initial display value
     parent::run();
 }
 /**
  * Initializes the widget.
  * This method will publish JUI assets if necessary.
  * It will also register jquery and JUI JavaScript files and the theme CSS file.
  * Added for multiple support: some callback JS functions
  */
 public function init()
 {
     parent::init();
     // ensure assets are published
     // add a couple JS functions used by the callbacks
     $js = "function split( val ) {\n        if(val) {\n          return val.split( /{$this->delimiter}\\s*/ );\n        }\n        return [];\n      }\n      function extractLast( term ) {\n        if(term) {\n          return split( term ).pop();\n        }\n        return [];\n      }";
     Yii::app()->getClientScript()->registerScript(__CLASS__ . '#functions', $js);
 }
Exemplo n.º 3
0
 public function run()
 {
     echo '<div class="control-group">';
     $htmlOptions['class'] = 'control-label';
     echo $this->form->labelEx($this->model, $this->attribute, $htmlOptions);
     echo '<div class="controls">';
     parent::run();
     echo $this->form->error($this->model, $this->attribute);
     echo "</div>";
     echo "</div>";
 }
 public function run()
 {
     // first render the FK field.  This is the actual data field, populated by autocomplete.select()
     if ($this->showFKField) {
         echo CHtml::activeTextField($this->model, $this->attribute, array('size' => $this->FKFieldSize, 'readonly' => 'readonly'));
     } else {
         echo CHtml::activeHiddenField($this->model, $this->attribute);
     }
     // second, the hidden field used to refresh the display value
     echo CHtml::hiddenField($this->_saveID, $this->_display, array('id' => $this->_saveID));
     // third, the autoComplete field itself
     $this->htmlOptions['id'] = $this->_lookupID;
     $this->htmlOptions['name'] = $this->_lookupID;
     parent::run();
     // fouth, an image button to empty all three fields
     // JJD 1/2/13 v1.6 use relNameLabel if present
     //$label=Yii::t('DR','Remove '). ucfirst((!empty($this->relNameLabel) ? $this->relNameLabel : $this->relName));
     //  $deleteImageURL = '/images/text_field_remove.png';
     //  echo CHtml::image($deleteImageURL, $label,
     //    array('title'=>$label,
     //         'name' => 'remove'.$this->_fieldID,
     //        'style'=>'margin-left:6px;',
     //         // JJD 4/27/12 #1350 trigger onchange event for display field, in case there's an event attached (e.g. unsaved-changes-warning)
     //       'onclick'=>"$('#".$this->_fieldID."').val('').trigger('change');$('#".$this->_saveID."').val('');$('#".$this->_lookupID."').val('');",
     //    )
     //  );
 }
 public function run()
 {
     // first render the FK field.  This is the actual data field, populated by autocomplete.select()
     if ($this->showFKField) {
         echo CHtml::activeTextField($this->model, $this->attribute, array('size' => $this->FKFieldSize, 'readonly' => 'readonly'));
     } else {
         echo CHtml::activeHiddenField($this->model, $this->attribute);
     }
     // second, the hidden field used to refresh the display value
     echo CHtml::hiddenField($this->_saveName, $this->_display);
     // third, the autoComplete field itself
     parent::run();
     // fouth, an image button to empty all three fields
     // first publish the delete.png from CGridView
     $deleteImageURL = Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('zii.widgets.assets.gridview') . '/delete.png');
     $label = Yii::t('app', 'Remove ') . ucfirst($this->relName);
     // TODO: how to translate relname ?
     echo CHtml::image($deleteImageURL, $label, array('title' => $label, 'name' => 'remove_' . $this->attribute, 'style' => 'margin-left:6px;', 'onclick' => "\$('#" . $this->_fieldName . "').val('');\$('#" . $this->_saveName . "').val('');\$('#" . $this->_lookupName . "').val('');"));
 }