/** * Initialize the nestedModels and availableModels */ public function init() { parent::init(); $this->_nestedModels = array(); $this->_availableModels = $this->itemsProvider->items; if (!empty($this->itemsProvider->nestedConfig)) { $this->initModels(CJSON::decode($this->itemsProvider->nestedConfig)); } //register the script function: nestedConfigToHidden $rootClass = $this->getOption('rootClass'); $stringify = $this->useJson2 ? 'JSON.stringify' : 'window.JSON.stringify'; $hiddenName = EMBConst::HIDDENNAME_NESTEDCONFIG; $function = "\$('#{$hiddenName}').val({$stringify}(\$('.{$rootClass}').nestable('serialize')));"; $script = 'function nestedConfigToHidden(){' . $function . '}'; Yii::app()->getClientScript()->registerScript('emb_tohidden_' . $this->getId(), $script, CClientScript::POS_END); $this->renderBeginForm(); }