Example #1
0
 public function activeJuiAutoComplete(CActiveForm $form, CModel $model, $attribute, $acRoute, $acValue, array $acOptions = array(), array $htmlOptions = array(), $loader = '/images/loader.gif')
 {
     $defaultAcOptions = array('minLength' => '3', 'select' => "js:{$attribute}_fillHidden", 'focus' => "js:{$attribute}_itemFocus", 'search' => "js:{$attribute}_initSearch", 'open' => "js:{$attribute}_finishedSearch");
     $acName = "{$attribute}_autocomplete";
     $_POST[$acName] = $acValue;
     echo $form->hiddenField($model, $attribute);
     $this->owner->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => $acName, 'value' => $acValue, 'sourceUrl' => $acRoute, 'options' => array_merge($defaultAcOptions, $acOptions), 'htmlOptions' => $htmlOptions));
     Yii::app()->clientScript->registerScript('jui_extras', "\n\t\t\tfunction {$attribute}_initSearch(e, ui) {\n\t\t\t\t\$(e.target).after('<img src=\"{$loader}\" class=\"loader\" alt=\"...\" />')\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tfunction {$attribute}_finishedSearch(e, ui) {\n\t\t\t\t\$(e.target).siblings('img').remove()\n\t\t\t\treturn true\n\t\t\t}\n\t\t\tfunction {$attribute}_fillHidden(e, ui) {\n\t\t\t\t\$('#" . get_class($model) . "_{$attribute}').val(ui.item.value)\n\t\t\t\t\$(e.target).val(ui.item.label)\n\t\t\t\treturn false\n\t\t\t}\n\t\t\tfunction {$attribute}_itemFocus(e, ui) {\n\t\t\t\t\$(e.target).val(ui.item.label)\n\t\t\t\treturn false\n\t\t\t}\n\t\t");
 }
Example #2
0
 /**
  * @inheritDoc
  */
 public function hiddenField($model, $attribute, $htmlOptions = array())
 {
     if (!$this->qualifyNames && !isset($htmlOptions['name'])) {
         $htmlOptions['name'] = $attribute;
     }
     if (!isset($htmlOptions['itemprop'])) {
         $htmlOptions['itemprop'] = $this->getItemPropName($attribute);
     }
     return parent::hiddenField($model, $attribute, $htmlOptions);
 }
Example #3
0
 public function getActionElements($controller, $action)
 {
     $form = new CActiveForm();
     $p = Yii::app()->createController($controller);
     if ($p && isset($p[0])) {
         $contObj = $p[0];
     } else {
         $contObj = array();
     }
     if ($contObj && ($actonArr = $contObj->actions())) {
         if (isset($actonArr[$action]) && $actonArr[$action]['class'] == 'CViewAction') {
             $path = $contObj->viewPath . '/pages';
             $files = array();
             if (is_dir($path)) {
                 foreach (scandir($path) as $file) {
                     if (strpos($file, '.php')) {
                         $name = str_replace('.php', '', $file);
                         $files[$name] = $name;
                     }
                 }
             }
             if ($files) {
                 return $form->dropDownList($this, 'element', $files, array()) . $form->hiddenField($this, 'elementmodel', array('value' => 'CViewAction'));
             }
         }
     }
     $actions = array();
     $controller = $_SERVER['DOCUMENT_ROOT'] . '/protected/controllers/' . $controller . 'Controller.php';
     $file = file_get_contents($controller);
     preg_match('!.*action' . $action . '(.*)!im', $file, $matches);
     if (isset($matches[1])) {
         preg_match('!\\/\\*(.*)\\*\\/!ism', $matches[1], $matches);
     }
     if (isset($matches[1])) {
         parse_str($matches[1]);
         //
         $criteria = new CDbCriteria();
         if ($condition) {
             $criteria->condition = $condition;
         }
         if ($order) {
             $criteria->order = $order;
         }
         $returmnodels = new $model();
         $returmnodels = $returmnodels->model()->findAll($criteria);
         $this->elementmodel = $model;
         if (isset($selectitem3)) {
             return $form->dropDownList($this, 'element', CHtml::listData($returmnodels, $selectitem1, $selectitem2, $selectitem3), array('prompt' => 'Выбирите...')) . $form->hiddenField($this, 'elementmodel');
         } else {
             return $form->dropDownList($this, 'element', CHtml::listData($returmnodels, $selectitem1, $selectitem2), array('prompt' => 'Выбирите...')) . $form->hiddenField($this, 'elementmodel');
         }
     } else {
         return '';
     }
 }
Example #4
0
 /**
  * Renders a hidden field for a model attribute.
  * @param CModel $parentModel the parent data model
  * @param string $attributedPath the attribute or path to related model attribute
  * @param array $htmlOptions additional HTML attributes.
  * @return string the generated input field
  */
 public function hiddenField($parentModel, $attributedPath, $htmlOptions = array())
 {
     list($model, $attribute, $htmlOptions) = self::resolveArgs($parentModel, $attributedPath, $htmlOptions);
     return parent::hiddenField($model, $attribute, $htmlOptions);
 }
    echo $form->hiddenField($model, "[{$i}]type");
    ?>
            <?php 
    echo $form->labelEx($model, "[{$i}]text");
    ?>
            <?php 
    echo $form->textArea($model, "[{$i}]text", array("rows" => 6, "cols" => 50, 'class' => 'required'));
    ?>
            <?php 
    echo $form->error($model, "[{$i}]text");
    ?>
        </div>

        <div class="field">
            <?php 
    echo $form->labelEx($model, "[{$i}]percent");
    ?>
            <?php 
    echo $form->textField($model, "[{$i}]percent", array("size" => 10, "maxlength" => 10, 'class' => 'range(1,100)'));
    ?>
            <?php 
    echo $form->error($model, "[{$i}]percent");
    ?>
        </div>

        <div class="field">
            <?php 
    echo $form->labelEx($model, "[{$i}]cost");
    ?>
            <?php 
    echo $form->textField($model, "[{$i}]cost", array("size" => 60, "maxlength" => 64));
    ?>
            <?php 
    echo $form->error($model, "[{$i}]cost");
    ?>
        </div>

        <div class="field">
            <?php 
    echo $form->labelEx($model, "[{$i}]price");
    ?>
            <?php 
    echo $form->textField($model, "[{$i}]price", array("size" => 9, "maxlength" => 9, 'class' => 'number'));
    ?>
            <?php 
    echo $form->error($model, "[{$i}]price");
    ?>
        </div>

        <div class="field">
            <?php 
    echo $form->labelEx($model, "[{$i}]limit");
    ?>
            <?php 
    echo CHtml::checkBox("unlim", true, array("id" => "limit_trig", "onclick" => '$(this).siblings("input").toggle();', "style" => "width:auto"));
    ?>
Неограничено
            <?php 
    echo $form->textField($model, "[{$i}]limit", array("size" => 10, "maxlength" => 10, "style" => "display:none"));
    ?>
            <?php 
    echo $form->error($model, "[{$i}]limit");
    ?>
        </div>

        <div class="field">
            <?php 
    echo $form->labelEx($model, "[{$i}]limit_per_user");
    ?>
            <?php 
    echo CHtml::checkBox("Coupon[{$i}][delete]", false, array("style" => "visibility:hidden", 'id' => "delete_{$i}"));
    ?>
            <?php 
    echo CHtml::checkBox("unlpu", true, array("id" => "lpu_trig", "onclick" => '$(this).siblings("input").toggle();', "style" => "width:auto"));
    ?>
Неограничено
            <?php 
    echo $form->textField($model, "[{$i}]limit_per_user", array("size" => 10, "maxlength" => 10, "style" => "display:none"));
    ?>
            <?php 
    echo $form->error($model, "[{$i}]limit_per_user");
    ?>
        </div>
    </div>
</a>
<?php 
}
?>
</div>
<?php 
$model = new Coupon();
?>
<script type="text/html" id="a-coupon" data-type="Купить скидку|Купить сертификат">
<a href="#edit" class="flag">
    <div class="percent">{{percent}}%</div>
        <div class="info">
                <div class="vd">{{price}} VD</div>
                <div class="buy">{{type}}</div>
        </div>
    <div class="hidden-form"></div>
</a>
</script>
<script type="text/html" id="coupon-form">
<div class="office-edit">
<div class="coupon-form form">
<?php 
echo CHtml::form("#");
?>
    <div class="field">
        <?php 
echo $form->hiddenField($model, "[{{id}}]type");