Exemple #1
0
 /**
  * Returns all profile field categories with some user data
  *
  * @todo Optimize me
  * @return Array ProfileFieldCategory
  */
 public function getProfileFieldCategories()
 {
     $categories = array();
     foreach (ProfileFieldCategory::find()->orderBy('sort_order')->all() as $category) {
         if (count($this->getProfileFields($category)) != 0) {
             $categories[] = $category;
         }
     }
     return $categories;
 }
Exemple #2
0
 /**
  * Returns The Form Definition to edit the ProfileField Model.
  *
  * @return Array CForm Definition
  */
 public function getFormDefinition()
 {
     $categories = ProfileFieldCategory::find()->orderBy('sort_order')->all();
     $profileFieldTypes = new fieldtype\BaseType();
     $definition = array('ProfileField' => array('type' => 'form', 'elements' => array('internal_name' => array('type' => 'text', 'maxlength' => 32, 'class' => 'form-control'), 'title' => array('type' => 'text', 'maxlength' => 32, 'class' => 'form-control'), 'description' => array('type' => 'textarea', 'class' => 'form-control'), 'sort_order' => array('type' => 'text', 'maxlength' => 32, 'class' => 'form-control'), 'translation_category' => array('type' => 'text', 'maxlength' => 32, 'class' => 'form-control', 'value' => $this->getTranslationCategory()), 'ldap_attribute' => array('type' => 'text', 'maxlength' => 255, 'class' => 'form-control'), 'required' => array('type' => 'checkbox'), 'visible' => array('type' => 'checkbox'), 'show_at_registration' => array('type' => 'checkbox'), 'editable' => array('type' => 'checkbox'), 'profile_field_category_id' => array('type' => 'dropdownlist', 'items' => \yii\helpers\ArrayHelper::map($categories, 'id', 'title'), 'class' => 'form-control'), 'field_type_class' => array('type' => 'dropdownlist', 'items' => $profileFieldTypes->getFieldTypes(), 'class' => 'form-control'))));
     // Field Type and Internal Name cannot be changed for existing records
     // So disable these fields.
     if (!$this->isNewRecord) {
         $definition['ProfileField']['elements']['field_type_class']['disabled'] = true;
         $definition['ProfileField']['elements']['internal_name']['readonly'] = true;
     }
     return $definition;
 }
Exemple #3
0
?>
</div>
    <div class="panel-body">

        <?php 
echo Html::a(Yii::t('AdminModule.views_userprofile_index', 'Add new category'), Url::to(['edit-category']), array('class' => 'btn btn-primary'));
?>

        <?php 
echo Html::a(Yii::t('AdminModule.views_userprofile_index', 'Add new field'), Url::to(['edit-field']), array('class' => 'btn btn-primary'));
?>

        <hr>
        <ul>
            <?php 
foreach (ProfileFieldCategory::find()->orderBy('sort_order')->all() as $category) {
    ?>
                <li>
                    <a href="<?php 
    echo Url::to(['edit-category', 'id' => $category->id]);
    ?>
">Category: <?php 
    echo Html::encode($category->title);
    ?>
</a>
                    <ul class="admin-userprofiles-fields">
                        <?php 
    foreach ($category->fields as $field) {
        ?>
                            <li class="admin-userprofiles-field" data-id="<?php 
        echo $field->id;