Yii Framework Forum: Yii-Bootstrap / Yii-Booster Empty Htmloptions Bug - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii-Bootstrap / Yii-Booster Empty Htmloptions Bug Rate Topic: -----

#1 User is offline   Trejder 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,197
  • Joined: 06-October 10
  • Location:Southern Poland

Posted 25 April 2013 - 05:49 AM

This is invalid. See below for more details.

Either I'm missing something obvious or Yii-Bootstrap / Yii-Booster extensions are somehow clearing (changing) $htmlOptions array used in TbActiveForm::error() and problably in some other places.

First, let's take a look, how this works when using base classes (CActiveForm).

This is the code in form view:

<?php 
    $validationArray = array
    (
        'hideErrorMessage'=>TRUE,
        'afterValidateAttribute'=>'js:afterValidateAttribute'
    );
?>

<?php echo('<pre>$validationArray = '.print_r($validationArray, TRUE).'</pre>'); ?>

<div class="row">
    ...
    <?php echo($form->error($model, 'name', $validationArray)); ?>
</div>

additional print_r() and die() are added as the first line of CActiveForm::error() function, to compare array that is passed and array that is received.

Running such configured script results in following screen output:

$validationArray = Array
(
    [hideErrorMessage] => 1
    [afterValidateAttribute] => js:afterValidateAttribute
)
 	
$htmlOptions = Array
(
    [hideErrorMessage] => 1
    [afterValidateAttribute] => js:afterValidateAttribute
)

What comes in must comes out, so everything is fine.

Now, take a look, what happens, when using TbActiveForm instead.

This is the view code (quite similar):

<?php 
    $validationArray = array
    (
        'hideErrorMessage'=>TRUE,
        'afterValidateAttribute'=>'js:afterValidateAttribute'
    );
?>

<?php echo('<pre>$validationArray = '.print_r($validationArray, TRUE).'</pre>'); ?>

<?php echo($form->textFieldRow($model, 'name', $htmlOptions + array('prepend'=>'ImiÄ™'))); ?>
<?php echo($form->error($model, 'name', $validationArray)); ?>

additional print_r() and die() are added as the first line of TbActiveForm::error() function as well.

And this is the screen output:

$validationArray = Array
(
    [hideErrorMessage] => 1
    [afterValidateAttribute] => js:afterValidateAttribute
)

$htmlOptions = Array
(
)

Can someone explain me, what is going on? Why this array is being cleared and where?

Proud Cookbook author, though still learning powerful Yii! :] See my generic profile for more information. Cheers!
0

#2 User is offline   Trejder 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,197
  • Joined: 06-October 10
  • Location:Southern Poland

Posted 25 April 2013 - 07:51 AM

This is invalid. Missed out, that htmlOptions for particular elements are passed not at first level of array, but rather as subarrays -- i.e. errorOptions, prependOptions, labelOptions etc.
Proud Cookbook author, though still learning powerful Yii! :] See my generic profile for more information. Cheers!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users