This extension is a widget to create Vista-like form buttons.
Currently, it supports these button types:
- Submit button
- Save button
- Reset button
- Cancel button.
Resources ¶
Documentation ¶
Requirements ¶
- Yii 1.0 or above
Installation ¶
- Extract the release file under
protected/extensions
Usage ¶
- Load the extension:
Yii::import('application.extensions.button.DDButton');
Use the widget in a form view.
Form Definition ¶
- Add an id to the form tag being created using beginForm():
<?php echo CHtml::beginForm(
array(
$update?'update':'create',
'id'=>$model->id
),
'POST',
array(
'id'=>'PostForm'
)
); ?>
Save button ¶
- In a view file:
<?php $this->widget( 'application.extensions.button.DDButton',
array(
'title'=>$update ? 'Save':'Create',
'linkTitle'=>$update ? 'Save this record' : 'Create this record',
'formID' => 'PostForm',
'buttonType' => 'save'
)); ?>
Reset Button ¶
<?php $this->widget( 'application.extensions.button.DDButton',
array(
'title'=>'Reset',
'linkTitle'=>'Reset the form data',
'formID' => 'PostForm',
'buttonType' => 'reset',
'confirm' => 'Really reset this form?'
)); ?>
Cancel button ¶
<?php $this->widget( 'application.extensions.button.DDButton',
array(
'title'=>'Cancel',
'linkTitle'=>'Cancel editing, back to list',
'formID' => 'PostForm',
'buttonType' => 'cancel',
'url' => array('post/admin')
)); ?>
Change Log ¶
August 20, 2010 - V0.2 ¶
- Button type 'cancel' now also uses 'confirm'
- Minor CSS changes on button link hover
April 5, 2010 ¶
- Added bits to documentation
April 1, 2010 ¶
- Initial release.
Well donw
Excellet work.
Problem in submit button
Hi! Nice work.
I have a problem with submit: if the form hasn't some other jquery calls, jQuery is undefined, so submit button doesn't work. I have changed to use getElementById, like reset button:
switch($this->buttonType) { case 'submit': case 'save': //$href = sprintf($href0,"jQuery('#{$this->formID}').submit();"); $href = sprintf($href0,"document.getElementById('{$this->formID}').submit();"); break;
Button that open java script
How to configure the button that open java script?...
Re: Problem in submit button
Simply include the jQuery lib using the
Yii::app()->clientScript->registerCoreScript('jquery')
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.