Helly everyone.
I want to create an Ajax button that will create a record, but I don’t have the Ajax concept, would anyone please create it for me.
The button should create a record and on successful creation it resides on the same page and just show a popup window to show that the "Item is added to the wishlist sucessfuly".
I have a wiki but due to lack of ajax knowledge I could do this for my requirement.
the wiki link is http://www.yiiframework.com/wiki/388/ajax-form-submiting-in-yii/
the button code is
<?php echo CHtml::link(Yii::t('site', 'Add to Wishlist'), array('/wishlist/create', 'item'=>$model->id, 'provider'=>$model->seller_id), array('class'=>'btn btn-lg btn-success')) ?>
and the wishlist form (which will create a wishlist record of the current user) is
<?php $form=$this->beginWidget('bootstrap.widgets.TbActiveForm',array(
'id'=>'wishlist-form',
'enableAjaxValidation'=>false,
)); ?>
<p class="help-block">Fields with <span class="required">*</span> are required.</p>
<?php echo $form->errorSummary($model); ?>
<?php echo $form->hiddenField($model,'item_id',array('class'=>'form-control', 'value'=>$_GET['item'])); ?>
<?php echo $form->hiddenField($model,'user_id',array('class'=>'form-control, 'value'=>$_GET['provider']')); ?>
<div class="form-actions">
<?php $this->widget('bootstrap.widgets.TbButton', array(
'buttonType'=>'submit',
'type'=>'primary',
'label'=>$model->isNewRecord ? 'Create' : 'Save',
)); ?>
</div>
<?php $this->endWidget(); ?>
Thanks in advance.