예제 #1
0
 /**
  * @param int $mode
  * @param string $value
  * @param array $config
  * @return string
  */
 protected function getActual($mode, $value, array $config = [])
 {
     switch ($mode) {
         case static::MODE_NAME_VALUE_AJAX:
         case static::MODE_MODEL_ATTRIBUTE_AJAX:
         case static::MODE_MODEL_ATTRIBUTE_VALUE_AJAX:
             /* @var $request \yii\tinymce\tests\Request */
             $request = Yii::$app->getRequest();
             $request->setIsAjax(true);
     }
     switch ($mode) {
         case static::MODE_NAME_VALUE:
         case static::MODE_NAME_VALUE_AJAX:
             Tinymce::$counter = 0;
             return Tinymce::widget(array_merge($config, ['name' => 'text', 'value' => $value]));
         case static::MODE_MODEL_ATTRIBUTE_VALUE:
         case static::MODE_MODEL_ATTRIBUTE_VALUE_AJAX:
             $model = new TestForm();
             if (array_key_exists('options', $config)) {
                 $config['options']['value'] = $value;
             } else {
                 $config['options'] = ['value' => $value];
             }
         case static::MODE_MODEL_ATTRIBUTE:
         case static::MODE_MODEL_ATTRIBUTE_AJAX:
             if (!isset($model)) {
                 $model = new TestForm();
                 $model->text = $value;
             }
             ob_start();
             ob_implicit_flush(false);
             $form = ActiveForm::begin();
             $actual = (string) $form->field($model, 'text', ['template' => '{input}'])->widget(Tinymce::className(), $config);
             ActiveForm::end();
             ob_end_clean();
             return $actual;
     }
     throw new Exception();
 }
예제 #2
0
 public function init()
 {
     parent::init();
     $this->widget(Tinymce::className(), ['options' => $this->inputOptions, 'clientOptions' => $this->pluginOptions]);
 }