Yii 1.1: yii-collapsible-fieldset

Create collapsible and expandable fieldsets
16 followers

JCollapsibleFieldset is a widget that encapsulates the jQuery coolfieldset plugin.
If you need to create collapsible and expandable fieldset to make large forms clear, this widget might be helpful.
The plugin was inspired by Drupal. Drupal does a great job in using collapsible fieldsets.

Requirements

Yii 1.1.6 or above

Usage

  • extract the file under .../protected/extensions
  • put in a view a code blocks like the following...
<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'login-form',
    'enableAjaxValidation'=>true,
)); ?>
 
<h2>Example 1 - Default state</h2>
    <?php $this->beginWidget('ext.coolfieldset.JCollapsibleFieldset', array(
        'legend'=>'Default'
    )); ?>
    <p>By default the <b>fieldset</b> is opened or expanded at start. Click on its <b>legend</b> to close or collapse it.</p>
    <?php $this->endWidget(); ?><!-- collabsible fieldset -->
 
<h2>Example 2 - Create only a fieldset without registration of Javascript/CSS-Files</h2>
    <?php $this->beginWidget('ext.coolfieldset.JCollapsibleFieldset', array(
        'onlyFieldset'=>true,
        'legend'=>'A normal Fieldset'
    )); ?>
    <p>For more details on how to further develop this application, please read
    the <a href="http://www.yiiframework.com/doc/">documentation</a>.
    Feel free to ask in the <a href="http://www.yiiframework.com/forum/">forum</a>,
    should you have any questions.</p>
    <?php $this->endWidget('ext.coolfieldset.JCollapsibleFieldset'); ?><!-- collabsible fieldset -->
 
<h2>Example 3 - Closed at start</h2>
    <?php $this->beginWidget('ext.coolfieldset.JCollapsibleFieldset', array(
        'collapsed'=>true,
        'legend'=>'Closed at start',
        'legendHtmlOptions'=>array('title'=>'Click me with the mouse!')
    )); ?>
<p>If we want the fieldset to be closed or collapsed at start, just set the property <b>{collapsed:true}</b>.</p>
    <?php $this->endWidget('ext.coolfieldset.JCollapsibleFieldset'); ?><!-- collabsible fieldset -->
<h2>Example 4</h2>
    <?php $this->beginWidget('ext.coolfieldset.JCollapsibleFieldset', array(
        'collapsed'=>false,
        'animation'=>false,
        'legend'=>'Notes :'
    )); ?>
    <ul>        
        <li>Edit the <b>jquery.coolfieldset.css</b> to change the fieldset style.</li>
    </ul>
    <?php $this->endWidget('ext.coolfieldset.JCollapsibleFieldset'); ?><!-- collabsible fieldset -->
 
    <div class="row buttons">
        <?php echo CHtml::submitButton('Login'); ?>
    </div>
 
<?php $this->endWidget(); ?>
</div><!-- form -->

Change log

Version 1.0

  • initial release

Version 1.1

  • published demo
  • code cleaning

Resources for the jQuery plugin

Total 4 comments

#13056 report it
taz at 2013/04/30 04:52pm
Animation example

Hi, does anyone have an example of animation config. I'm not sure what should I put instead of 'animation'=>false,

Thanks

#5361 report it
Alex Adams at 2011/10/06 10:55pm
Fieldset collapse and expand control in pagers

I love this tool. It works great on the initial load of a page. My issue is that I am using it inside views in CListView widgets inside portlets and I page past the initial page load. When I use the pager in CListView where there are coolfieldsets, all sets are then expanded in the widget. They will not collapse at all, not even if I page back to page one. The only thing that will correct it is to refresh the entire page, thus initializing the portlets and widgets and fieldsets.

Is there any way to work around this?

Thanks,

Alex

#3677 report it
jacmoe at 2011/04/27 12:17pm
Wrong library

May I suggest that this extension be rewritten for jQuery-Collapse instead? It's a cooler extension under a much better license. :)

#3589 report it
Joblo at 2011/04/20 07:47pm
Wrong license

Nice extension I would like to use, but I have a problem with the kind of opensource license. I don't want to use GPL code in my software products.

The coolfieldset jQuery plugin is licensed under GPL. So I think you can't publish this extension under 'New BSD License'.

Leave a comment

Please to leave your comment.

Create extension