Commits

robr...@localhost  committed 8fefd96

Fixed bug when assigning MANY_MANY relations when creating/updating models

  • Participants
  • Parent commits 0e2464b

Comments (0)

Files changed (4)

 AweCrud Change Log
 ===============
 
+Version 0.14, 2013-05-31
+* Fixed bug when assigning MANY_MANY relations when creating/updating models
+
 Version 0.13, 2013-05-03
 * Added suport to MANY_MANY relations (even if no 3rd party extension is provided)
 * Fixed i18n bug in "create" view. Thanks to @ben_rivero

File components/AweHtml.php

         // a string or an array of strings with the pk values.
         if ((is_object($value) && is_subclass_of($value, 'AweActiveRecord')) ||
             (is_array($value) && !empty($value) && is_object($value[0]) && is_subclass_of(
-                $value[0],
-                'AweActiveRecord'
-            ))
+                    $value[0],
+                    'AweActiveRecord'
+                ))
         ) {
             return self::getPrimaryKey($value, true);
         } else {
         }
     }
 
-    public static function formatUrl($url, $inNewTab = false) {
+    public static function formatUrl($url, $inNewTab = false)
+    {
         $value = $url;
-        if (strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0)
+        if (strpos($url, 'http://') !== 0 && strpos($url, 'https://') !== 0) {
             $url = 'http://' . $url;
+        }
         $htmlOptions = array();
-        if ($inNewTab)
+        if ($inNewTab) {
             $htmlOptions['target'] = '_blank';
+        }
         return CHtml::link(CHtml::encode($value), $url, $htmlOptions);
     }
 
         if ($model === null) {
             return null;
         }
-        if (!is_array($model)) {
+        if (is_string($model)) {
+            return $model;
+        } elseif (!is_array($model)) {
             $pk = $model->getPrimaryKey();
             if ($forceString && is_array($pk)) {
                 $pk = implode($model->pkSeparator, $pk);

File generators/AweCrud/templates/default/create.php

 
 <fieldset>
     <legend><?php echo "<?php echo Yii::t('AweCrud.app', 'Create') . ' ' . {$this->modelClass}::label(); ?>" ?></legend>
-    <?php echo "<?php echo \$this->renderPartial('_form', array('model' => \$model)); ?>".PHP_EOL; ?>
+    <?php echo "<?php \$this->renderPartial('_form', array('model' => \$model)); ?>".PHP_EOL; ?>
 </fieldset>

File generators/AweCrud/templates/default/update.php

 
 <fieldset>
     <legend><?php echo "<?php echo Yii::t('AweCrud.app', 'Update') . ' ' . {$this->modelClass}::label(); ?> <?php echo CHtml::encode(\$model) ?>" ?></legend>
-    <?php echo "<?php echo \$this->renderPartial('_form',array('model' => \$model)); ?>".PHP_EOL; ?>
+    <?php echo "<?php \$this->renderPartial('_form',array('model' => \$model)); ?>".PHP_EOL; ?>
 </fieldset>