Permalink
Browse files

Ajax form improvements.

  • Loading branch information...
thelfensdrfer committed Aug 23, 2012
1 parent 9813f88 commit 8a284ec339bc278a8aac26faaa05a579e4d01b64
Showing with 37 additions and 3 deletions.
  1. +31 −1 EBootstrapActiveForm.php
  2. +6 −2 css/bootstrap.css
View
@@ -5,7 +5,7 @@
* Apply bootstrap style to the form
*
* @author Tim Helfensdörfer <tim@visualappeal.de>
- * @version 0.3.5
+ * @version 0.4.4
* @package bootstrap.yiiwidgets
*/
class EBootstrapActiveForm extends CActiveForm {
@@ -23,13 +23,27 @@ class EBootstrapActiveForm extends CActiveForm {
*/
public $errorMessageCssClass = 'help-inline';
+ /**
+ * If it's set to false the EBootstrap css file will be included (specially for ajax validation errors)
+ * If it's set null no css file will be included
+ *
+ * @since 0.4.4
+ */
+ public $cssFile = false;
+
/**
* Init the widget
*/
public function init() {
if ($this->horizontal)
EBootstrap::mergeClass($this->htmlOptions, array('form-horizontal'));
+ if ($this->cssFile === false) {
+ $cssFile = dirname(__FILE__).'/css/bootstrap.css';
+ $this->cssFile = Yii::app()->getAssetManager()->publish($cssFile);
+ Yii::app()->clientScript->registerCssFile($this->cssFile);
+ }
+
parent::init();
}
@@ -200,6 +214,22 @@ public function helpBlock($help) {
return $html;
}
+ /**
+ * Returns a inline help
+ *
+ * Help inline is displayed right next to the input field (where the error should be displayed)
+ *
+ * @since 0.4.4
+ * @param string $help Help message
+ */
+ public function helpInline($help) {
+ $html = EBootstrap::openTag('span', array('class' => 'help-inline'));
+ $html .= $help;
+ $html .= EBootstrap::closeTag('span');
+
+ return $html;
+ }
+
/**
* Render a submit buttom
*
View
@@ -8,7 +8,11 @@
.clearfix:after {
clear: both;
}
-/** EBootstrapListView */
+/* EBootstrapActiveForm Ajax Validation (The Yii validation generates different classes than bootstrap) */
+.error .help-inline, .error input {
+ color: #9d261d!important;
+}
+/* EBootstrapListView */
.bootstrap-list-view .summary {
font-style: italic;
}
@@ -45,7 +49,7 @@
.bootstrap-list-view .bootstrap-list-view-item:last-child {
margin-bottom: 0;
}
-/** EBootstrapGridView */
+/* EBootstrapGridView */
.bootstrap-grid-view .summary {
font-style: italic;
}

0 comments on commit 8a284ec

Please sign in to comment.