Jeditable widget

This extension encapsulates the JEditable library into a widget, which can be used in CForm definitions or anywhere you want in-place editable content.

jeditable extension

Hi,

could you put some example code which show how to use this extension with Model?

Hi,

I’ve used this mostly with CForms, so here’s some code which will connect a CForm to a CModel (it should support any subclass of CModel (including ActiveRecord and FormModel), with editable title and body elements:

In your controller:




function actionUpdate()

{

  ...

  $model = new Post();

  $form = new CForm('application.forms.Post', $model, $this);

  if($form->submitted('submit')) {

    if($model->save()) {

      Yii::app()->user->setFlash('success', 'Saved model successfully');

      $this->redirect(array('show', 'id' => $model->id));

    }

  }

  $this->render('update', array('form' => $form));

}



In protected/application/forms/Post.php:




return array(

  'showErrorSummary' => true,

  'elements' => array(

    'title' => array('type' => 'application.extensions.ds.jeditable.DsJEditableWidget', 'jeditable_type' => 'text', 'size' => 60, 'maxlength' => 255),

    'body' => array('type' => 'application.extensions.ds.jeditable.DsJEditableWidget', 'jeditable_type' => 'textarea', 'rows' => 10, 'cols' => 60),

    ...

  ),

  'buttons' => array(

    'submit' => array('type' => 'submit', 'label' => 'Save'),

  )

);



Then in your update view file at protected/views/post/update.php:




...

$form->render();

...



You will have to correct your aliases so they point to the location of the widget. I put all my extensions into a subfolder ‘ds’. YMMV.

Note that the elements array must be indexed with an existing attribute on the model, or the element will not show up on your form.

i already figured out my issue:)

Hello. I want to extend Jeditable widget, but I have a problem. I’m trying to put TinyMCE on the textarea that Jeditable generates. I have read the documentation here and here, but still haven’t done something that works. When I click on the div which I want to edit, the script generates me one input field with the data in it, but still no TinyMCE. I will be very happy if someone help me.

Hi :

I want to use this extension in my application to enable users edit comments on post.

This is my code :





<?php if($comentario->autor_id==(Yii::app()->user->id)){ ?>

 <?php echo CHtml::beginForm(); ?>

  <? $this->widget('application.extensions.jeditable.DsJEditableWidget', array('jeditable_type' => 'textarea', 'model' => $comentario, 'attribute' => 'texto')) ?>

 <?php echo CHtml::endForm(); ?>						

<?php } ?>




I don’t know if this is possible and if this is the right way

  • Where I put the url action for save the input content?

Thanks


return array(

  'showErrorSummary' => true,

  'elements' => array(

    'title' => array('type' => 'application.extensions.ds.jeditable.DsJEditableWidget', 'jeditable_type' => 'text', 'size' => 60, 'maxlength' => 255),

    'body' => array('type' => 'application.extensions.ds.jeditable.DsJEditableWidget', 'jeditable_type' => 'textarea', 'rows' => 10, 'cols' => 60),

    ...

  ),

  'buttons' => array(

    'submit' => array('type' => 'submit', 'label' => 'Save'),

  )

);

This returns

Looking inside the code, I see that actually a bunch of the parameters are not defined???

I’ve been looking into this and the page is rendered correctly, but when I try to update the field, the whole code of the page is submitted.


	$this->widget(

		'application.extensions.jeditable.DsJEditableWidget', 

		array(

			'jeditable_type' => 'text',

			'model'=>$data,

			'attribute'=>'user_dep',

			'id'=>'user_'.$data->user_id.'_dep',

			'width'=>'20',

		)

	);



working fine and rendering


<form id="user-form" action="/yii/myapp/index.php/user/update/id/2" method="post"><div id="user_2_dep" name="user[user_dep]">OGC</div></form>

When I click the div, it transforms into an inputbox, so far so good.

When submitting the data, it seems the (html)code for the whole page is posted and put into the div.

Any help would be appreciated.

Hi

I would like to create a Customize Datagrid Column which implements Jeditable

So I create a new file,

this file extends CGridColumn

and then I override the renderDataCellContent($row,$data){}

But when I try




protected function renderDataCellContent($row,$data)

	{

	

		echo $this->grid->owner->widget(

                'application.extensions.jeditable.DsJEditableWidget', 

                array(

                        'jeditable_type' => 'text',

                        'model'=>$data,

                        'attribute'=>$this->value,

                        'id'=>$data->tableSchema->name[$this->name],                		

                        'width'=>'200',

                )

        );

       

	}



I’ve got the error : Object of class DsJEditableWidget could not be converted to string

I need your help…

thanks

My be because you echo it