Waiting for widget load


I have been using CKeditor widget to enrich one of my input textareas.

This works like a charm and the data store is as it should be. The problem araises when i want to edit a particuler entry in my database.

The layout create/update is autogenerated by gii and i only customized 1 textarea. When i want to edit an entry, the customized textarea loads as one of the last components and loads empty.

I’m guessing it’s not populated with the corrosponding data as the data load occurs before the widget is able to contain the data.

So, how do i either:

  1. Make yii wait for the widget to finish loading before populating the various fields with data

  2. Define a onLoad event where the widget pulls the data when it is ready for it

Thanks in advance and if you can help, just small words and elaborate what needs doing as im a novice at this

Regars Rasmus W

as far as i know WYSIWYG editors just load the content of the <textarea> and have nothing to do with loading, are you sure the name etc are still the same on the edit so it doesn’t try to show a field that isn’t actually there (so it shows empty)

could you provide the code of your model/update view ?

Hep hey.

I am assuming that when yii is able to extract the content of my widget, it should be able to place said content back into the widget when i want to edit that record. But im very new at this so might be happening stuff behind the bag that i know nothing off.

My update view is unchanged and auto generated.

Here is my _form.php from my model "content", the only place where i did any changes.

<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(



)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">

		<?php echo $form->labelEx($model,'overskrift'); ?>

		<?php echo $form->textField($model,'overskrift',array('size'=>40,'maxlength'=>40)); ?>

		<?php echo $form->error($model,'overskrift'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'indhold'); ?>

		[b]<?php $this->widget('ext.ckeditor.CKEditorWidget',array(

  "model"=>$model,                 # Data-Model

  "attribute"=>'indhold',          # Attribute in the Data-Model

  'id' =>'something', 

  'htmlOptions'=>array('id' => 'stuff'), # Optional



  "config" => array(






  #Optional address settings if you did not copy ckeditor on application root


                                  # Path to ckeditor.php


                                  # Realtive Path to the Editor (from Web-Root)

  ) );


		[u]echo $form->textArea($model,'indhold',array('rows'=>6, 'cols'=>50)); [/u]

		<?php echo $form->error($model,'indhold'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'metaoverskrift'); ?>

		<?php echo $form->textArea($model,'metaoverskrift',array('rows'=>6, 'cols'=>50)); ?>

		<?php echo $form->error($model,'metaoverskrift'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'metabeskrivelse'); ?>

		<?php echo $form->textArea($model,'metabeskrivelse',array('rows'=>6, 'cols'=>50)); ?>

		<?php echo $form->error($model,'metabeskrivelse'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'metasogeord'); ?>

		<?php echo $form->textArea($model,'metasogeord',array('rows'=>6, 'cols'=>50)); ?>

		<?php echo $form->error($model,'metasogeord'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'kategoriid'); ?>

		<?php echo $form->dropDownList($model,'kategoriid', CHtml::listData(kategori::model()->findAll(), 'id', 'navn')); ?>

		<?php echo $form->error($model,'kategoriid'); ?>


	<div class="row buttons">

		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>


<?php $this->endWidget(); ?>

</div><!-- form -->

i bolded the part which i changed. The original textarea is just outside the php snippet as plain text (underlined)

Okay, i think i found a solution to my little problem.

I did not get it to work the way i wanted (where either the program waited for the widget or visa vasa) but i remembered that the widget had a “Defaultvalue” attribute which i set to $model[‘my database coloum’].

This ment that if i was in create state, the window was left blank (as the model’s database colum was not yet set) and when i wanted to edit a entry, the field would get populated by the correct data onces the widget had loaded.

peace out