addCssStyle() public static méthode

Appends a CSS style string to the given options.
public static addCssStyle ( string $style, array &$htmlOptions ) : array
$style string the CSS style string.
$htmlOptions array the options.
Résultat array the options.
 /**
  * Initializes the widget.
  */
 public function init()
 {
     parent::init();
     Yii::import('bootstrap.behaviors.TbWidget');
     $this->attachBehavior('tbWidget', new TbWidget());
     if (!isset($this->assetPath)) {
         $this->assetPath = Yii::getPathOfAlias('lib.bootstrap-wysihtml5');
     }
     if (!$this->bindPlugin) {
         $this->htmlOptions['data-plugin'] = 'wysihtml5';
         $this->htmlOptions['data-plugin-options'] = CJSON::encode($this->pluginOptions);
     }
     TbHtml::addCssStyle('width: ' . $this->width . 'px; height: ' . $this->height . 'px;', $this->htmlOptions);
 }
Exemple #2
0
 /**
  * Displays a summary of validation errors for one or several models.
  * @param mixed $models the models whose input errors are to be displayed.
  * @param string $header a piece of HTML code that appears in front of the errors
  * @param string $footer a piece of HTML code that appears at the end of the errors
  * @param array $htmlOptions additional HTML attributes to be rendered in the container div tag.
  * @return string the error summary. Empty if no errors are found.
  */
 public function errorSummary($models, $header = null, $footer = null, $htmlOptions = array())
 {
     if (!$this->enableAjaxValidation && !$this->enableClientValidation) {
         return TbHtml::errorSummary($models, $header, $footer, $htmlOptions);
     }
     TbArray::defaultValue('id', $this->id . '_es_', $htmlOptions);
     $html = TbHtml::errorSummary($models, $header, $footer, $htmlOptions);
     if ($html === '') {
         if ($header === null) {
             $header = '<p>' . Yii::t('yii', 'Please fix the following input errors:') . '</p>';
         }
         TbHtml::addCssClass(TbHtml::$errorSummaryCss, $htmlOptions);
         TbHtml::addCssStyle('display:none', $htmlOptions);
         $html = CHtml::tag('div', $htmlOptions, $header . '<ul><li>dummy</li></ul>' . $footer);
     }
     $this->summaryID = $htmlOptions['id'];
     return $html;
 }
 public function testAddCssStyle()
 {
     $htmlOptions = array('style' => 'display: none');
     TbHtml::addCssStyle('color: purple', $htmlOptions);
     TbHtml::addCssStyle('background: #fff;', $htmlOptions);
     TbHtml::addCssStyle(array('font-family: "Open sans"', 'font-weight: bold;'), $htmlOptions);
     $this->assertEquals('display: none; color: purple; background: #fff; font-family: "Open sans"; font-weight: bold', $htmlOptions['style']);
 }