Yii Framework Forum: Jeditable widget - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Jeditable widget In-place editing in forms and views

#1 User is offline   datashaman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 27-September 09
  • Location:Cape Town, South Africa

Posted 07 October 2009 - 04:27 AM

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
0

#2 User is offline   qwerty 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 315
  • Joined: 20-November 08

Posted 07 October 2009 - 05:06 PM

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

#3 User is offline   datashaman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 56
  • Joined: 27-September 09
  • Location:Cape Town, South Africa

Posted 08 October 2009 - 12:05 AM

View Postqwerty, on 07 October 2009 - 05:06 PM, said:

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.
0

#4 User is offline   smeto 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 14-August 09

Posted 24 October 2009 - 06:38 AM

i already figured out my issue:)

This post has been edited by smeto: 24 October 2009 - 11:48 AM

0

#5 User is offline   koleto 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 07-July 09
  • Location:Bulgaria

Posted 16 January 2010 - 05:13 PM

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.
I want to fix the world but they won't give me the source code
0

#6 User is offline   netbur 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 42
  • Joined: 03-June 09

Posted 19 January 2010 - 07:58 AM

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
0

#7 User is offline   ptoly 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 03-August 09

Posted 19 January 2010 - 01:40 PM

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

Quote

CException

Description
Property "DsJEditableWidget.size" is not defined.


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

#8 User is offline   plantin 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 21
  • Joined: 02-June 10

Posted 16 June 2010 - 09:54 AM

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.
0

#9 User is offline   chtibob69 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 13-February 11

Posted 18 April 2011 - 08:15 AM

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
0

#10 User is offline   Mohamed Khalil 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 09-May 11

Posted 29 December 2011 - 09:39 AM

View Postchtibob69, on 18 April 2011 - 08:15 AM, said:

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
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users