fillFromConfig([ 'readOnly', 'disabled', 'allowCopy', 'hiddenPlaceholder', 'hideOnTabChange', ]); if ($this->formField->disabled || $this->formField->readOnly) { $this->previewMode = true; } } /** * @inheritDoc */ public function render() { $this->prepareVars(); return $this->makePartial('sensitive'); } /** * Prepares the view data for the widget partial. */ public function prepareVars() { $this->vars['readOnly'] = $this->readOnly; $this->vars['disabled'] = $this->disabled; $this->vars['hasValue'] = !empty($this->getLoadValue()); $this->vars['allowCopy'] = $this->allowCopy; $this->vars['hiddenPlaceholder'] = $this->hiddenPlaceholder; $this->vars['hideOnTabChange'] = $this->hideOnTabChange; } /** * Reveals the value of a hidden, unmodified sensitive field. * * @return array */ public function onShowValue() { return [ 'value' => $this->getLoadValue() ]; } /** * @inheritDoc */ public function getSaveValue($value) { if ($value === $this->hiddenPlaceholder) { $value = $this->getLoadValue(); } return $value; } /** * @inheritDoc */ protected function loadAssets() { $this->addCss('css/sensitive.css', 'core'); $this->addJs('js/sensitive.js', 'core'); } }