Yii Framework Forum: CJuiInputWidget or alternative - Yii Framework Forum

Jump to content

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

CJuiInputWidget or alternative Rate Topic: -----

#1 User is offline   Jaz Manister 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 109
  • Joined: 27-October 09
  • Location:Rural Western New York, USA

Posted 12 January 2010 - 12:29 PM

Hi, I'm looking at making a form with a drop down box where if the option is not in the box, I want to do a pop-up (modal) form to add this component via ajax and update the list. For now, my difficulty is understanding what widget/extension to use for this. With zii out now, I'm a little confused what to use. There's a CJuiInputWidget in zii and a nice looking JUI extension available. Both seem to offer solutions, but I can't get either to work. I would love if someone could show me a simple example of how to properly implement the CJuiInputWidget or similar widget.

Thanks
0

#2 User is offline   Jaz Manister 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 109
  • Joined: 27-October 09
  • Location:Rural Western New York, USA

Posted 12 January 2010 - 01:34 PM

Here's what I've got going so far that appears as though it will do the trick. Please let me know if this is not the right technique.

$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
    'id'=>'mydialog',
    // additional javascript options for the dialog plugin
    'options'=>array(
        'title'=>'Add New Supplier',
        'autoOpen'=>false,
		'modal'=>true,
		'buttons'=>array(
			'Add Item'=>'js:addSupplier',
			'Cancel'=>'js:function(){ $(this).dialog("close");}',
		),
    ),
));

$supplier = new Supplier;
echo CHtml::activeLabelEx($supplier, 'supplier_name');
echo CHtml::activeTextField($supplier, 'supplier_name');

$this->endWidget('zii.widgets.jui.CJuiDialog');

// the link that may open the dialog
echo CHtml::link('open dialog', '#', array(
   'onclick'=>'$("#mydialog").dialog("open"); return false;',
));


So this is basically the sample snippet given with the CJuiDialog. To get fields into the dialog, I created them myself in the content section. I will then harness javascript to ajax the new item and update my drop-down. Is this the right way?
0

#3 User is offline   Zeljko 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 12-January 10

Posted 12 January 2010 - 01:50 PM

View PostJaz Manister, on 12 January 2010 - 01:34 PM, said:

Here's what I've got going so far that appears as though it will do the trick. Please let me know if this is not the right technique.

$this->beginWidget('zii.widgets.jui.CJuiDialog', array(
    'id'=>'mydialog',
    // additional javascript options for the dialog plugin
    'options'=>array(
        'title'=>'Add New Supplier',
        'autoOpen'=>false,
		'modal'=>true,
		'buttons'=>array(
			'Add Item'=>'js:addSupplier',
			'Cancel'=>'js:function(){ $(this).dialog("close");}',
		),
    ),
));

$supplier = new Supplier;
echo CHtml::activeLabelEx($supplier, 'supplier_name');
echo CHtml::activeTextField($supplier, 'supplier_name');

$this->endWidget('zii.widgets.jui.CJuiDialog');

// the link that may open the dialog
echo CHtml::link('open dialog', '#', array(
   'onclick'=>'$("#mydialog").dialog("open"); return false;',
));


So this is basically the sample snippet given with the CJuiDialog. To get fields into the dialog, I created them myself in the content section. I will then harness javascript to ajax the new item and update my drop-down. Is this the right way?


I would do that way also. Creating InputWidget doesn't seem right for what you are trying to accomplish. You sould create widget when there is possibility to reuse code.
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