コード例 #1
0
    /**
     * @inheritdoc
     */
    public function clientValidateAttribute($model, $attribute, $view)
    {
        $attributeID = Html::getInputId($model, $attribute);
        $typeAttributeID = Html::getInputId($model, $this->typeAttribute);
        $view->registerJs('
            $("#' . $typeAttributeID . '").on("change", function(){
                var $type = $(this);
                var $code = $("#' . $attributeID . '");
                var $yiiActiveFormData = $code.closest("form").yiiActiveForm("data");

                $.each($yiiActiveFormData.attributes, function () {
                    if(this.id == "' . $attributeID . '") this.status = 2;
                });
            });
            $( document ).ready(function() {
                $("#' . $typeAttributeID . '").trigger("change");
            });
        ');
        if ($this->type) {
            return $this->getAdapter($model)->clientValidateAttribute($model, $attribute, $view);
        } else {
            BarcodeAsset::register($view);
            $options = $this->getClientOptions($model, $attribute);
            return 'yii.validation.barcode(value, messages, ' . json_encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . ');';
        }
    }
コード例 #2
0
 /**
  * @inheritdoc
  */
 public function clientValidateAttribute($model, $attribute, $view)
 {
     BarcodeAsset::register($view);
     return null;
 }