Пример #1
0
 /**
  * TbActiveForm::textFieldRow() with min/max character length support.
  * @param  CiiSettingsModel $model       The model that we are operating on
  * @param  string           $property    The name of the property we are working with
  * @param  array            $htmlOptions An array of HTML Options
  * @param  CValidator       $validators  The Validator(s) for this property
  *                                       Since we already have it, it's worth passing through
  */
 public function textFieldRowLabelFix($model, $property, $htmlOptions = array(), $validators = NULL)
 {
     if ($validators !== NULL) {
         foreach ($validators as $k => $v) {
             if (get_class($v) == "CStringValidator") {
                 if (isset($v->min)) {
                     $htmlOptions['min'] = $v->min;
                 }
                 if (isset($v->max)) {
                     $htmlOptions['max'] = $v->max;
                 }
             }
             if (get_class($v) == "CRequiredValidator") {
                 $htmlOptions['required'] = true;
             }
         }
     }
     $htmlOptions['value'] = $model->{$property};
     $htmlOptions['type'] = 'text';
     $htmlOptions['id'] = get_class($model) . '_' . $property;
     $htmlOptions['name'] = get_class($model) . '[' . $property . ']';
     echo CHtml::tag('label', array(), CiiInflector::underscoretowords($model->getAttributeLabel($property)) . (Cii::get($htmlOptions, 'required', false) ? CHtml::tag('span', array('class' => 'required'), ' *') : NULL));
     echo CHtml::tag('input', $htmlOptions);
 }
Пример #2
0
 /**
  * Renders the main body content
  * @param  CActiveForm $form  The Form we're working with
  */
 private function renderMain($form)
 {
     // #main .content
     echo CHtml::openTag('div', array('id' => 'main', 'class' => 'nano'));
     echo CHtml::openTag('div', array('class' => 'nano-content'));
     echo CHtml::openTag('fieldset');
     // If we want a custom form view, render that view instead of the default behavior
     if ($this->model->form !== NULL) {
         $this->controller->renderPartial($this->model->form, array('model' => $this->model, 'properties' => $this->properties, 'form' => $form));
     } else {
         if (count($this->properties) == 0) {
             echo CHtml::tag('legend', array(), Yii::t('Dashboard.main', 'Change Theme Settings'));
             echo CHtml::tag('div', array('class' => 'alert alert-info'), Yii::t('Dashboard.main', 'There are no settings for this section.'));
         } else {
             $groups = $this->model->groups();
             if (!empty($groups)) {
                 foreach ($groups as $name => $attributes) {
                     echo CHtml::tag('legend', array(), $name);
                     echo CHtml::tag('div', array('class' => 'clearfix'), NULL);
                     foreach ($attributes as $property) {
                         $p = new StdClass();
                         $p->name = $property;
                         $this->renderProperties($form, $p);
                     }
                 }
             } else {
                 echo CHtml::tag('legend', array(), CiiInflector::titleize(get_class($this->model)));
                 foreach ($this->properties as $property) {
                     $this->renderProperties($form, $property);
                 }
             }
         }
     }
     echo CHtml::closeTag('div');
     echo CHtml::closeTag('div');
     echo CHtml::closeTag('div');
 }
Пример #3
0
 /**
  * Converts a table name to its class name according to rails
  * naming conventions.
  *
  * Converts "people" to "Person"
  *
  * @access public
  * @static
  * @see tableize
  * @param    string    $table_name    Table name for getting related ClassName.
  * @return string SingularClassName
  */
 public static function classify($table_name)
 {
     return CiiInflector::camelize(CiiInflector::singularize($table_name));
 }