Yii 1.1: fancy-buttons

Widget to create fancy Vista-like form buttons
4 followers

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.

Total 4 comments

#5684 report it
MetaYii at 2011/11/01 02:42pm
Re: Problem in submit button

Simply include the jQuery lib using the

Yii::app()->clientScript->registerCoreScript('jquery')
#4540 report it
Peter JK at 2011/07/19 01:25am
Button that open java script

How to configure the button that open java script?...

#3903 report it
cecilio at 2011/05/19 02:03pm
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;
#580 report it
Francis.TM at 2010/04/19 03:51am
Well donw

Excellet work.

Leave a comment

Please to leave your comment.

Create extension
  • Yii Version: 1.1
  • License: New BSD License
  • Developed by: jwerner
  • Category: User Interface
  • Votes: +1 / -1
  • Downloaded: 1,031 times
  • Created on: Apr 1, 2010
  • Last updated: Aug 30, 2010