2017 © Pedro Peláez
 

library zf-snap-jquery

jQuery and jQuery UI helpers and form elements for Zend Framework 2

image

snapshotpl/zf-snap-jquery

jQuery and jQuery UI helpers and form elements for Zend Framework 2

  • Thursday, May 15, 2014
  • by snapshotpl
  • Repository
  • 3 Watchers
  • 9 Stars
  • 8,359 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 3 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

ZfSnapJquery

jQuery and jQuery UI helpers and form elements for Zend Framework 2, (*1)

Version 0.5.0 Created by Witold Wasiczko, (*2)

Features

Usage

Create form:, (*3)

add(array(
            'name' => 'slider',
            'type' => 'Slider',
        ));

        $this->add(array(
            'name' => 'spinner',
            'type' => 'Spinner',
        ));

        $this->add(array(
            'name' => 'datepicker',
            'type' => 'Datepicker',
        ));

        $this->add(array(
            'name' => 'autocomplete',
            'type' => 'Autocomplete',
            'attributes' => array(
                'jquery' => array(
                    'source' => array(
                        'Zend Framework',
                        'Symfony2',
                        'CakePHP',
                        'Kohana',
                        'Yii',
                    )
                )
            )
        ));

        $this->add(array(
            'name' => 'submit',
            'attributes' => array(
                'type'  => 'submit',
                'value' => 'Submit ZfSnapJquery form!',
            ),
        ));
    }
}
```

Assign form to view in controller:

```php
public function indexAction()
{
    $sl = $this->getServiceLocator();

    $form = $sl->get('FormElementManager')->get('\Application\Form\Jquery');

    return new ViewModel(array(
        'form' => $form,
    ));
}
```
and print it in view:
```php
form()->openTag($this->form); ?>



Slider: formJquerySlider($this->form->get('slider')); ?>
Spinner: formJquerySpinner($this->form->get('spinner')); ?>
Date picker: formJqueryDatepicker($this->form->get('datepicker')); ?>
Autocomplete: formJqueryAutocomplete($this->form->get('autocomplete')); ?>
formSubmit($this->form->get('submit')); ?>
form()->closeTag() ?>

That's it! Oh, and you need to print Zend's headLink(), headScript() and inlineScript() in your layout., (*4)

Customization

Custom jQuery UI element property

To change jquery options use jquery attribute:, (*5)

$this->add(array(
    'name' => 'autocomplete',
    'type' => 'Autocomplete',
    'attributes' => array(
        'jquery' => array(
            'source' => 'data-source.php',
        ),
    ),
));

Custom version, theme or CDN

If you need to change version, theme or default CDN - overwrite configuration:, (*6)

return array(
    'zf_snap_jquery' => array(
        'libraries' => array(
            'jquery' => array(
                'version' => '2.0.3',
                'cdnScript' => \ZfSnapJquery\Libraries\Jquery::CDN_GOOGLE,
            ),
            'jquery-ui' => array(
                'version' => '1.10.0',
                'theme' => 'black-tie',
            ),
        ),
    ),
);

Custom scripts and styles

You can use your own script or style:, (*7)

return array(
    'zf_snap_jquery' => array(
        'libraries' => array(
            'jquery' => array(
                'script' => 'url/to/script/jquery.min.js',
            ),
            'jquery-ui' => array(
                'script' => 'other/url/to/script/jquery-ui.min.js',
                'style' => 'url/to/style/jquery-ui.min.css',
            ),
        ),
    ),
);

Custom helper

If you don't want to use headLink(), headScript() and inlineScript() to include scripts and styles:, (*8)

return array(
    'zf_snap_jquery' => array(
        'view-helpers' => array(
            'jquery' => array(
                'appendToOwnHelper' => false,
            ),
        ),
    ),
);

And then in your layout:, (*9)

echo $this->jquery();

Custom way to append scripts or styles

To disable appending scripts and styles:, (*10)

return array(
    'zf_snap_jquery' => array(
        'libraries' => array(
            'jquery' => array(
                'enable' => false,
            ),
            'jquery-ui' => array(
                'enable' => false,
            ),
        ),
    ),
);

To see what you can customize see source of module.config.php., (*11)

How to install?

Via composer.json, (*12)

{
    "require": {
        "snapshotpl/zf-snap-jquery": "dev-master"
    }
}

The Versions

15/05 2014

dev-master

9999999-dev

jQuery and jQuery UI helpers and form elements for Zend Framework 2

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

jquery javascript zf2 zend framework jquery-ui

15/05 2014

0.5.1

0.5.1.0

jQuery and jQuery UI helpers and form elements for Zend Framework 2

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

jquery javascript zf2 zend framework jquery-ui

10/10 2013

0.5.0

0.5.0.0

jQuery and jQuery UI helpers and form elements for Zend Framework 2

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.3

 

The Development Requires

jquery javascript zf2 jquery-ui