Затык, друзья на самом простом, ужс.
решил подключить визуальный редактор
подключил аж но 2
ext.imperavi-redactor
и
yii-tinymce.TinyMce от Богдана
Самый прикол, все отображается ровно и даже загрузчики картинок работают, а изменения не пишуться в БД
а если все оставить как есть:
echo $form->textArea($model,'content',array('rows'=>5, 'cols'=>50, 'class'=>'input-xxlarge'));
все пишется!
Че за ерунда?!
Заголовок формы такой,
Код: Выделить всё
$form=$this->beginWidget('CActiveForm', array(
'id'=>'news-form',
'htmlOptions'=>array('autocomplete'=>'off',
'enctype'=>'multipart/form-data',
),
// Please note: When you enable ajax validation, make sure the corresponding
// controller action is handling ajax validation correctly.
// There is a call to performAjaxValidation() commented in generated controller code.
// See class documentation of CActiveForm for details on this.
'enableAjaxValidation'=>false,
));
Код: Выделить всё
<?php echo $form->labelEx($model,'content'); ?>
<?php //echo $form->textArea($model,'content',array('rows'=>5, 'cols'=>50, 'class'=>'input-xxlarge')); ?>
<?
//Yii::import('ext.imperavi-redactor-widget-master.ImperaviRedactorWidget');
/*
$this->widget('ImperaviRedactorWidget', array(
// You can either use it for model attribute
'model' => $model,
'attribute' => 'content',
// or just for input field
//'name' => 'content',
// Some options, see http://imperavi.com/redactor/docs/
'options' => array(
'imageUpload'=>$this->createUrl('imgUpload'),
'imageUploadErrorCallback'=>'js:function(obj, json){ alert(json.error); }', // function to show upload error to user
'fileUpload'=>$this->createUrl('fileUpload'),
'fileUploadErrorCallback'=>'js:function(obj, json){ alert(json.error); }',
// if you are using CSRF protection – add following:
'uploadFields'=>array(
Yii::app()->request->csrfTokenName => Yii::app()->request->csrfToken,
),
'lang' => 'ru',
'toolbar' => true,
'iframe' => false,
'css' => 'wym.css',
),
'htmlOptions'=>array(
'rows'=>25,
'cols'=>200,
'style'=>'width:90%;height:500px;'
),
));
*/
$this->widget('ext.yii-tinymce.TinyMce', array(
'model' => $model,
'attribute' => 'content',
// Optional config
//'spellcheckerUrl' => array('tinyMce/spellchecker'),
// or use yandex spell: http://api.yandex.ru/speller/doc/dg/tasks/how-to-spellcheck-tinymce.xml
'spellcheckerUrl' => 'http://speller.yandex.net/services/tinyspell',
'fileManager' => array(
'class' => 'ext.elFinder.TinyMceElFinder',
'connectorRoute'=>'admin/elfinder/connector',
),
'htmlOptions' => array(
'rows' => 6,
'cols' => 60,
),
));
?>
посмотрел HTML на выходе все ровно кажись
Код: Выделить всё
<div class="row">
<label for="News_content">Текст</label> <textarea rows="6" cols="60" id="News_content" name="News[content]">07 января завершился VI Фестиваль итальянской кухни “BUONA ITALIA 2013”. Грандиозное мероприятие проходило в блестящем банкетном зале комплекса Korston Hotels Moscow. В этот вечер рестораны-участники Фестиваля еще раз представили гостям самые необыкновенн</textarea> </div>
Код: Выделить всё
public function actionUpdate($id)
{
$model = $this->loadModel($id);
// Uncomment the following line if AJAX validation is needed
// $this->performAjaxValidation($model);
if(isset($_POST['News']))
{
$model->attributes = $_POST['News'];
$model->uploadImg = CUploadedFile::getInstance($model,'uploadImg');
$model->uploadPre = CUploadedFile::getInstance($model,'uploadPre');
if ($model->uploadImg) {
$sourcePathLogo = pathinfo($model->uploadImg->getName());
$sourcePathExtLogo = $sourcePathLogo['extension'];
$arrayExtLogo = array('jpg', 'png', 'gif');
$file_name_logo = self::newFileNameLogo($id, $sourcePathExtLogo);
$model->logo = $file_name_logo;
//Генерируем новое имя картинки
}
if ($model->uploadPre) {
$sourcePathPre = pathinfo($model->uploadPre->getName());
$sourcePathExtPre = $sourcePathPre['extension'];
$arrayExtPre = array('jpg', 'png', 'gif');
$file_name_preview = self::newFileNamePre($id, $sourcePathExtPre);
$model->preview = $file_name_preview;
//Генерируем новое имя картинки
}
$model->lastupdate = time();
if($model->save())
Yii::app()->user->setFlash('updateNews','Вы удачно обновили информацию');
if ($model->uploadImg && (in_array($sourcePathExtLogo, $arrayExtLogo, true))==TRUE)
{
$model->uploadImg->saveAs('upload/news/logo/'.$file_name_logo);
$image = Yii::app()->image->load('upload/news/logo/'.$file_name_logo);
//$image->resize(100, 100);
$image->quality(100)->crop(200, 200);
$image->save();
}
if ($model->uploadPre && (in_array($sourcePathExtPre, $arrayExtPre, true))==TRUE)
{
$model->uploadPre->saveAs('upload/news/preview/'.$file_name_preview);
$image = Yii::app()->image->load('upload/news/preview/'.$file_name_preview);
//$image->resize(100, 100);
$image->quality(100)->crop(600, 350);
$image->save();
}
$this->redirect(array('view','id'=>$model->id));
}
$this->render('update',array(
'model'=>$model,
));
}