Esempio n. 1
0
            <?php 
echo \humhub\modules\user\widgets\UserPicker::widget(array('inputId' => 'recipient', 'model' => $model, 'attribute' => 'recipient', 'userGuid' => Yii::$app->user->guid, 'placeholderText' => Yii::t('MailModule.views_mail_create', 'Add recipients'), 'focus' => true));
?>

            <div class="form-group">
                <?php 
echo $form->field($model, 'title');
?>
            </div>

            <div class="form-group">
                <?php 
echo $form->field($model, 'message', ['inputOptions' => ['class' => 'form-control', 'id' => 'newMessageText']])->textarea();
?>
                <?php 
echo \humhub\widgets\MarkdownEditor::widget(array('fieldId' => 'newMessageText'));
?>
            </div>

        </div>
        <div class="modal-footer">
            <?php 
echo \humhub\widgets\AjaxButton::widget(['label' => Yii::t('MailModule.views_mail_create', 'Send'), 'ajaxOptions' => ['type' => 'POST', 'success' => 'function(html){ $("#globalModal").html(html); }', 'url' => Url::to(['/mail/mail/create'])], 'htmlOptions' => ['class' => 'btn btn-primary']]);
?>

            <button type="button" class="btn btn-primary" data-dismiss="modal"><?php 
echo Yii::t('MailModule.views_mail_create', 'Close');
?>
</button>

        </div>
            <?php 
echo $form->labelEx($page, 'title');
?>
            <?php 
echo $form->textField($page, 'title', array('class' => 'form-control', 'placeholder' => Yii::t('CustomPagesModule.views_admin_edit', 'Page title')));
?>
        </div>

        <?php 
if ($page->type == ContainerPage::TYPE_MARKDOWN) {
    ?>
            <?php 
    echo $form->textArea($page, 'page_content', array('id' => 'markdownField', 'class' => 'form-control', 'rows' => '15', 'placeholder' => Yii::t('CustomPagesModule.views_admin_edit', 'Content')));
    ?>
            <?php 
    echo \humhub\widgets\MarkdownEditor::widget(['fieldId' => 'markdownField']);
    ?>
        <?php 
} elseif ($page->type == ContainerPage::TYPE_LINK || $page->type == ContainerPage::TYPE_IFRAME) {
    ?>
            <div class="form-group">
                <?php 
    echo $form->labelEx($page, 'url');
    ?>
                <?php 
    echo $form->textField($page, 'url', array('class' => 'form-control', 'placeholder' => Yii::t('CustomPagesModule.views_admin_edit', 'URL')));
    ?>
            </div>
        <?php 
}
?>
Esempio n. 3
0
 public function renderField($name, $definition, $forms)
 {
     $output = "";
     // Determine Model
     $model = null;
     foreach ($forms as $formName) {
         if (isset($this->models[$formName])) {
             $model = $this->models[$formName];
         }
     }
     if ($model == null && $this->primaryModel !== null) {
         $model = $this->primaryModel;
     }
     if ($model) {
         $options = [];
         if (isset($definition['id'])) {
             $options['id'] = $definition['id'];
         }
         if (isset($definition['readonly']) && $definition['readonly']) {
             $options['readOnly'] = true;
             $options['disabled'] = true;
         }
         if (isset($definition['value'])) {
             $options['value'] = $definition['value'];
         }
         if (isset($definition['prompt']) && $definition['prompt']) {
             $options['prompt'] = $definition['prompt'];
         }
         if (isset($definition['label']) && $definition['label']) {
             $options['label'] = $definition['label'];
         }
         if (isset($definition['type'])) {
             switch ($definition['type']) {
                 case 'text':
                     return $this->form->field($model, $name)->textInput($options);
                 case 'multiselectdropdown':
                     $options['class'] = 'form-control multiselect_dropdown';
                     $options['multiple'] = 'multiple';
                     return $this->form->field($model, $name)->listBox($definition['items'], $options);
                 case 'dropdownlist':
                     return $this->form->field($model, $name)->dropDownList($definition['items'], $options);
                 case 'checkbox':
                     if (isset($options['readOnly']) && $options['readOnly']) {
                         $options['disabled'] = 'disabled';
                     }
                     return $this->form->field($model, $name)->checkbox($options);
                 case 'textarea':
                     return $this->form->field($model, $name)->textarea($options);
                 case 'hidden':
                     return $this->form->field($model, $name)->hiddenInput($options)->label(false);
                 case 'password':
                     return $this->form->field($model, $name)->passwordInput($options);
                 case 'datetime':
                     $format = Yii::$app->formatter->dateFormat;
                     if (isset($definition['format'])) {
                         $format = $definition['format'];
                     }
                     $yearRange = isset($definition['yearRange']) ? $definition['yearRange'] : date('Y') - 100 . ":" . (date('Y') + 100);
                     return $this->form->field($model, $name)->widget(\yii\jui\DatePicker::className(), ['dateFormat' => $format, 'clientOptions' => ['changeYear' => true, 'yearRange' => $yearRange, 'changeMonth' => true, 'disabled' => isset($options['readOnly']) && $options['readOnly']], 'options' => ['class' => 'form-control']]);
                 case 'markdown':
                     $options['id'] = $name;
                     $returnField = $this->form->field($model, $name)->textarea($options);
                     $returnField .= \humhub\widgets\MarkdownEditor::widget(array('fieldId' => $name));
                     return $returnField;
                 default:
                     return "Field Type " . $definition['type'] . " not supported by Compat HForm";
             }
         } else {
             return "No type found for: FieldName: " . $name . " Forms: " . print_r($forms, 1) . "<br>";
         }
     } else {
         return "No model for: FieldName: " . $name . " Forms: " . print_r($forms, 1) . "<br>";
     }
     return $output;
 }