protected function appendScript(Tag $tag, Renderer $renderer)
    {
        /* @var $form \Sirius\Input\InputFilter */
        $form = $tag->get('_form');
        $rules = array();
        $messages = array();
        foreach ($form->getValidator()->getRules() as $selector => $valueValidator) {
            /* @var $valueValidator \Sirius\Validation\ValueValidator */
            foreach ($valueValidator->getRules() as $rule) {
                /* @var $rule \Sirius\Validation\Rule\AbstractRule */
                $clientSideRule = $this->getClientSideRule($rule);
                if ($clientSideRule) {
                    $rules[$selector][$clientSideRule['name']] = $clientSideRule['options'];
                    $messages[$selector][$clientSideRule['name']] = $rule->getPotentialMessage()->__toString();
                }
            }
        }
        if (!$tag->get('id')) {
            $tag->set('id', 'f' . rand(1, 1000));
        }
        $formId = $tag->get('id');
        $rules = json_encode($rules);
        $messages = json_encode($messages);
        $script = <<<JSCRIPT
<script>
jQuery && jQuery('#{$formId}').validate({
    rules: {$rules},
    messages: {$messages},
    errorElement: 'div',
    errorClass: 'error',
    errorPlacement: function(error, element) {
        // Append error within linked label
        error.addClass('alert alert-danger');
        \$( element ).closest( ".form-group" ).prepend( error );
    },
});
</script>
JSCRIPT;
        $tag->after($script);
    }
 protected function addInputClass(Tag $tag)
 {
     $input = $tag->getInput();
     // if input but not radioset or checboxset
     if ($input instanceof Input && !$input instanceof Radioset && !$input instanceof Checkboxset) {
         $input->addClass('form-control');
     } elseif ($input instanceof Radioset || $input instanceof Checkboxset) {
         // for items with less then 4 items the list is inline
         if (4 > count($tag->get('_element')->get(Specs::OPTIONS))) {
             $input->addClass('list-unstyled');
         } else {
             $input->addClass('list-inline');
         }
     }
 }