<?php if ($model->Menu) { ?> <?php echo $form->dropDownListControlGroup($model, 'parent', $model->Menu->getItemDropDownList()); ?> <?php } ?> <div class="form-group"> <?php $Content = new Content(); ?> <?php echo BsHtml::activeLabel($model, 'content_id', array('class' => 'control-label col-lg-2', 'label' => 'Link to Content')); ?> <div class="col-lg-10"> <?php $this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => 'page_autocomplete', 'value' => $model->Content ? $model->Content->title : '', 'source' => $this->createUrl('content/autocomplete'), 'options' => array('minLength' => '2', 'select' => 'js:function(event,ui){ $("input#MenuItem_content_id").val(ui.item.value); $(this).val(ui.item.label); return false; }'), 'htmlOptions' => array('class' => 'form-control'))); ?> <?php if ($model->Content) { ?> <p class="help-block">Currently linked to: <?php echo CHtml::link($model->Content->title, array('content/update', 'id' => $model->Content->id)); ?>
/** * Generates a control group with a text field using a juidatepicker for a model attribute. * @param CModel $model the data model. * @param string $attribute the attribute name. * @param array $htmlOptions additional HTML attributes. * @return string the generated row. * @see BsHtml::activeDateFieldControlGroup */ public function datetimeFieldControlGroup($model, $attribute, $htmlOptions = array()) { $allowEmpty = false; $validators = $model->getValidators($attribute); foreach ($validators as $validator) { if ($validator instanceof CDateValidator && $validator->allowEmpty === true) { $allowEmpty = true; break; } } //I would have liked to have used the i18n date format, but the Jui Datepicker //doesn't support the unicode date format //$dateFormat = Yii::app()->locale->getDateFormat('full'); $htmlOptions = BsHtml::addClassName('form-control', $htmlOptions); $htmlOptions['displaySize'] = isset($htmlOptions['displaySize']) ? $htmlOptions['displaySize'] : 1; $dateWidget = $this->widget('zii.widgets.jui.CJuiDatePicker', array('name' => $attribute . '_widget', 'htmlOptions' => $htmlOptions, 'options' => array('dateFormat' => 'DD, d MM yy', 'altFormat' => 'yy-mm-dd', 'altField' => '#' . CHtml::activeId($model, $attribute), 'changeYear' => true, 'changeMonth' => true), 'value' => date('l, j F Y', strtotime($model->{$attribute}))), true); $hourOptions = array(); $minuteOptions = array(); for ($i = 0; $i < 24; $i++) { $val = str_pad($i, 2, "0", STR_PAD_LEFT); $hourOptions[$val] = $val; } for ($i = 0; $i < 60; $i += 5) { $val = str_pad($i, 2, "0", STR_PAD_LEFT); $minuteOptions[$val] = $val; } $rowHtmlOptions = $htmlOptions; $rowHtmlOptions['input'] = '<div class="row">'; if ($allowEmpty) { $rowHtmlOptions['input'] .= '<div class="col-lg-1">' . BsHtml::activeLabel($model, $attribute . '_set', array('class' => 'control-label')) . BsHtml::activeCheckBox($model, $attribute . '_set', array('class' => 'control-label')) . '</div>'; } $rowHtmlOptions['input'] .= '<div class="col-lg-4">' . BsHtml::label('Date', $attribute . '_widget', array('class' => 'control-label')) . $dateWidget . '</div><div class="col-lg-2">' . BsHtml::activeLabel($model, $attribute . '_hour', array('class' => 'control-label')) . BsHtml::activeDropDownList($model, $attribute . '_hour', $hourOptions, $htmlOptions) . '</div><div class="col-lg-2">' . BsHtml::activeLabel($model, $attribute . '_minute', array('class' => 'control-label')) . BsHtml::activeDropDownList($model, $attribute . '_minute', $minuteOptions, $htmlOptions) . '</div></div>'; $rowHtmlOptions = $this->processRowOptions($model, $attribute, $rowHtmlOptions); return BsHTML::activeDateFieldControlGroup($model, $attribute, $rowHtmlOptions) . BsHTML::activeHiddenField($model, $attribute); }