Commits

David Lukas committed f77c74f

Add support for prepended / appended icons

Comments (0)

Files changed (3)

 Supported versions
 ------------------
 
-- [Zend Framework 2.0.0rc5 - 1 (commit 0598a05ba1)](https://github.com/zendframework/zf2/tree/0598a05ba145b453eeb5c98512f6cdcfb00b9416)
+- [Zend Framework 2.0.0rc5 - 16 (commit 57c7d09278)](https://github.com/zendframework/zf2/tree/57c7d09278d0f2db3a1c1a63eac4277f9ab7cf72)
 - Twitter Bootstrap v2.1.0
 
 IMPORTANT: If the module does not seem to work, check the version of your ZF2 library and update to the version **and commit**

config/module.config.php

          ),
     ),
     'dlu_tw_bootstrap'  => array(
-        'sup_ver_zf2'       => '2.0.0rc5 - 1 (commit 0598a05ba1)',
+        'sup_ver_zf2'       => '2.0.0rc5 - 16 (commit 57c7d09278)',
         'sup_ver_twb'       => '2.1.0',
     ),
 );

src/DluTwBootstrap/Form/View/Helper/FormTextTwb.php

         $this->prepareElementBeforeRendering($element, $formType, $displayOptions);
         $html   = parent::render($element);
         //Text prepend / append
-        $escapeHelper   = $this->getEscapeHtmlHelper();
-        $prepAppClass   = '';
-        if($element->getOption('prependText')) {
+        $escapeHelper       = $this->getEscapeHtmlHelper();
+        $escapeAttribHelper = $this->getEscapeHtmlAttrHelper();
+        $prepAppClass       = '';
+        //Prepend icon (not possible on Search forms)
+        if (($formType != FormUtil::FORM_TYPE_SEARCH) && array_key_exists('prependIcon', $displayOptions)) {
+            $prepAppClass   = $this->genUtil->addWords('input-prepend', $prepAppClass);
+            $html           = sprintf('<span class="add-on"><i class="%s"></i></span>%s',
+                                      $escapeAttribHelper($displayOptions['prependIcon']), $html);
+        }
+        //Prepend text
+        if ($element->getOption('prependText')) {
             $prepAppClass   = $this->genUtil->addWords('input-prepend', $prepAppClass);
             $html           = '<span class="add-on">' . $escapeHelper($element->getOption('prependText')) . '</span>'
-                . $html;
+                            . $html;
+        }
+        //Append icon (not possible on Search forms)
+        if (($formType != FormUtil::FORM_TYPE_SEARCH) && array_key_exists('appendIcon', $displayOptions)) {
+            $prepAppClass   = $this->genUtil->addWords('input-append', $prepAppClass);
+            $html           .= sprintf('<span class="add-on"><i class="%s"></i></span>',
+                                      $escapeAttribHelper($displayOptions['appendIcon']));
         }
-        if($element->getOption('appendText')) {
+        //Append text
+        if ($element->getOption('appendText')) {
             $prepAppClass   = $this->genUtil->addWords('input-append', $prepAppClass);
             $html           .= '<span class="add-on">' . $escapeHelper($element->getOption('appendText')) . '</span>';
         }
-        if($prepAppClass) {
+        if ($prepAppClass) {
             $html           = '<div class="' . $prepAppClass . '">' . "\n$html\n" . '</div>';
         }
         return $html;