Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
UserProfileEditWidget.php
1 <div class="user-profile-edit-widget">
2  <a name="UserProfileEditWidget"></a>
3 
4  <h2><?php echo UserModule::t('Edit profile'); ?></h2>
5 
6  <?php if (Yii::app()->user->hasFlash('approveState')): ?>
7  <div class="success">
8  <?php echo Yii::app()->user->getFlash('approveState'); ?>
9  </div>
10  <?php endif; ?>
11 
12  <?php if (Yii::app()->user->hasFlash('profileMessage')): ?>
13  <div class="success">
14  <?php echo Yii::app()->user->getFlash('profileMessage'); ?>
15  </div>
16  <?php endif; ?>
17  <div class="form">
18  <?php $form = $this->beginWidget('CActiveForm', array(
19  'id' => 'profile-form',
20  'action' => Yii::app()->createUrl('/user/profile/edit/', array('return_url' => Yii::app()->request->getRequestUri() . '#UserProfileEditWidget')),
21  'enableAjaxValidation' => true,
22  'clientOptions' => array(
23  'validateOnSubmit' => true
24  ),
25  'htmlOptions' => array('enctype' => 'multipart/form-data'),
26  )); ?>
27 
28  <p class="note"><?php echo UserModule::t('Fields with <span class="required">*</span> are required.'); ?></p>
29 
30  <?php echo $form->errorSummary(array($model, $profile)); ?>
31  <div class="row">
32  <?php echo $form->labelEx($model, 'username'); ?>
33  <?php echo $form->textField($model, 'username', array('size' => 20, 'maxlength' => 20)); ?>
34  <?php echo $form->error($model, 'username'); ?>
35  </div>
36  <div class="nofloat"></div>
37 
38  <div class="row">
39  <?php echo $form->labelEx($model, 'email'); ?>
40  <?php echo $form->textField($model, 'email', array('size' => 60, 'maxlength' => 128)); ?>
41  <?php echo $form->error($model, 'email'); ?>
42  </div>
43  <?php
44  $profileFields = $profile->getFields();
45  if ($profileFields) {
46  foreach ($profileFields as $field) {
47  ?>
48  <div class="row">
49  <?php echo $form->labelEx($profile, $field->varname);
50 
51  if ($widget = $field->widgetEdit($profile)) {
52  echo $widget;
53  } elseif ($field->range) {
54  /* we should display corresponding field based on it's content*/
55  $pos = strpos($field->range, '-');
56 
57  if ($pos === false) {
58  /* show as dropdown box */
59  echo $form->dropDownList($profile, $field->varname, Profile::range($field->range));
60  } else {
61  $tag = substr($field->range, 0, $pos);
62  switch ($tag) {
63  case 'checkbox':
64  $field->range = substr($field->range, $pos + 1);
65  /* show as checkbox */
66  echo $form->checkBox($profile, $field->varname, Array('uncheckValue' => ""));
67  break;
68  case 'radio':
69  $field->range = substr($field->range, $pos + 1);
70  echo $form->radioButtonList($profile, $field->varname, Profile::range($field->range), array('labelOptions' => Array('class' => 'inline_label')));
71  break;
72  case 'select':
73  $field->range = substr($field->range, $pos + 1);
74  echo $form->dropDownList($profile, $field->varname, Profile::range($field->range));
75  break;
76  default:
77  echo $form->dropDownList($profile, $field->varname, Profile::range($field->range));
78  }
79  }
80  } elseif ($field->field_type == "TEXT") {
81  echo $form->textArea($profile, $field->varname, array('rows' => 6, 'cols' => 50));
82  } else {
83  echo $form->textField($profile, $field->varname, array('size' => 60, 'maxlength' => (($field->field_size) ? $field->field_size : 255)));
84  }
85  echo $form->error($profile, $field->varname); ?>
86  </div>
87  <div class="nofloat"></div>
88  <?php
89  }
90  }
91  ?>
92 
93  <div class="nofloat"></div>
94 
95  <div class="row buttons">
96  <?php echo CHtml::submitButton($model->isNewRecord ? UserModule::t('Create') : UserModule::t('Save')); ?>
97  </div>
98 
99  <?php $this->endWidget(); ?>
100 
101  </div>
102  <!-- form -->
103 </div>