Zend Framework Source Code Snippets

Multiselectable

Bookmark and Share
1
2
3
4
56
7
8
9
1011
12
13
14
1516
17
18
19
2021
<?php 
 
class MyApp_Form_Decorator_Multiselectable extends Zend_Form_Decorator_Abstract
{
                public function render($content)
        {
                
                $view = $this->getElement()->getView();
                $view->headScript()                        ->appendFile($view->baseUrl().'/js/multiselectable.js')
                        ->appendScript(
                                '$(document).ready(function() {' .
                                        '$('.'.$this->getElement()->getAttrib('class').'').multiselectable();' .
                        '}); '                        );
                $view->headLink()->appendStylesheet($view->baseUrl().'/css/multiselectable.css');
                return $content;
        }
        }
1
2
3
4
56
7
8
9
1011
12
13
14
//Example usage:
$this->addPrefixPath('MyApp_Form_Decorator', 'MyApp/Form/Decorator', 'decorator')
 
$this->addElement('multiselect', 'test', array(
        'label' => 'Test Multiselect',        'class' => 'test-multiselectable',
        'decorators' => array(
                'Multiselectable',
                'ViewHelper'
        ),        'multioptions' => array(
                1,2,3,4,5,6,7,8,9,0
        )
));

Comments

Ben Ben
1 year ago

This is just a test!

You must login before commenting on a snippet. If you do not have an account, please register.

Snippet description

Use this in conjunction with the Multiselectable jQuery plugin available from http://akibjorklund.com/code/multiselectable

Place the first snippet in a file called Multiselectable.php in the /library/MyApp/Form/Decorator folder.
Place the multiselectable.js in the /public/js folder.
Place the multiselectable.css in the /public/css folder.
Ensure you have
echo $this->headScript();
and
echo $this->headLink();
in your layout.phtml file. Look these up in the Zend Framework reference if you don't have them.

Snippet details

Created:
Matt Matt
1 year ago
Edited:
Matt Matt
1 year ago
Revision Id:
148
Edit Message:
Initial Release
ZF Version
1.8.3
Tags:
form decorator jQuery multiselectable javascript
Comments:
1
Views:
5004
Points:
0 (0 votes)

History

r148

Initial Release

Matt Matt
1 year ago
diff
r147

Initial Release

Matt Matt
1 year ago