public function actionGetVariations() { if (Yii::app()->request->isAjaxRequest && isset($_POST['product'])) { $product = Products::model()->findByPk($_POST['product']); echo CHtml::hiddenField('product_id', $product->product_id); if ($variations = $product->getVariations()) { foreach ($variations as $variation) { $field = "Variations[{$variation[0]->specification_id}][]"; echo '<div class="shop-variation-element">'; echo '<strong>' . CHtml::label($variation[0]->specification->title . '</strong>', $field, array('class' => 'lbl-header')); if ($variation[0]->specification->required) { echo ' <span class="required">*</span>'; } echo '<br />'; if ($variation[0]->specification->input_type == 'textfield') { echo CHtml::textField($field); } else { if ($variation[0]->specification->input_type == 'select') { // If the specification is required, preselect the first field. // Otherwise let the customer choose which one to pick // $product->variationCount > 1 ? true : false means, that the // widget should display the _absolute_ price if only 1 variation // is available, otherwise the relative (+ X $) echo CHtml::radioButtonList($field, $variation[0]->specification->required ? $variation[0]->id : null, ProductVariation::listData($variation, $product->variationCount > 1 ? true : false), array('template' => '{input} {label}', 'separator' => '<div class="clear"></div>')); } } echo '</div>'; } } } else { throw new CHttpException(404); } }
public function run() { list($name, $id) = $this->resolveNameID(); if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $this->htmlOptions['id'] = $this->hidden ? $id . '_hidden' : $id; } if (isset($this->htmlOptions['name'])) { $name = $this->htmlOptions['name']; } else { $this->htmlOptions['name'] = $this->hidden ? $name . '_hidden' : $name; } if ($this->hasModel()) { echo $this->hidden ? BsHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions) : BsHtml::activeTelFieldControlGroup($this->model, $this->attribute, $this->htmlOptions); } else { echo $this->hidden ? CHtml::hiddenField($name, $this->value, $this->htmlOptions) : CHtml::textField($name, $this->value, $this->htmlOptions); } $options = CJavaScript::encode($this->options); $js = "jQuery('#{$id}').{$this->mode}picker({$options});"; if (isset($this->language)) { $this->registerScriptFile($this->i18nScriptFile); $js = "jQuery('#{$id}').{$this->mode}picker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));"; } $cs = Yii::app()->getClientScript(); $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'); $cs->registerCssFile($assets . self::ASSETS_NAME . '.css'); $cs->registerScriptFile($assets . self::ASSETS_NAME . '.js', CClientScript::POS_END); $cs->registerScript(__CLASS__, $this->defaultOptions ? 'jQuery.{$this->mode}picker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : ''); $cs->registerScript(__CLASS__ . '#' . $id, $js); }
/** * @param array $options * @return string */ public function formButton($options = array()) { $form = CHtml::beginForm($this->url(), 'get'); $form .= CHtml::hiddenField('business', $this->business); foreach (CMap::mergeArray($this->defaultOptions, $options) as $k => $v) { $form .= CHtml::hiddenField($k, $v); } $form .= CHtml::imageButton($this->image, array('border' => 0, 'alt' => $this->imageAltText)); $form .= CHtml::endForm(); return $form; }
public function showLangModal() { $language = Yii::app()->params['language']; $this->beginWidget('bootstrap.widgets.TbModal', array('id' => $this->modalId, 'htmlOptions' => array('style' => 'margin-top:-200px;', 'backdrop' => 'static'))); echo "<div class=\"modal-header\">\n <h4 style=\"width:30%;display: inline-block;\">翻译</h4> \n <span id='" . $this->modalId . "message' style=\"margin-left:30px;color:red;\"></span>\n </div>"; echo "<div id='" . $this->modalId . "ModalBody' class=\"modal-body\" style=\"text-align:center\">"; $tableName = $this->model->tableName(); $attribute = $this->attribute; echo CHtml::hiddenField('tableName', $tableName); echo CHtml::hiddenField('attribute', $attribute); $pk = $this->model->primaryKey; echo CHtml::activeHiddenField($this->model, $this->model->pk, array('name' => 'pk')); $result = Translation::model()->find('model=:tableName and pk=:pk and attribute=:attribute', array(':tableName' => $tableName, ':pk' => $pk, ':attribute' => $attribute)); $data = json_decode($result->data); foreach ($language as $key => $value) { if (strtolower($key) == 'zh_cn') { continue; } echo "<div><span style='width:80px !important;display: inline-block;'>" . $value . '</span>' . CHtml::textField($key, $data->{$key}) . "</div>"; } echo "</div>"; echo "<div class=\"modal-footer\" style=\"text-align: center;\">"; $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'button', 'type' => 'info', 'label' => '保存', 'htmlOptions' => array('id' => $this->modalId . 'save'))); echo " "; $this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'button', 'label' => '取消', 'htmlOptions' => array("data-dismiss" => "modal", 'id' => $this->modalId . 'back'))); echo "</div>"; $this->endWidget(); }
public function run() { echo CHtml::hiddenField($this->name, '', array('id' => $this->id . '_hidden')); //beckause disabled elements no serialize echo CHtml::activeTextField($this->model, $this->attribute, array('class' => 'text')); echo '<div class="alias_preloader" ></div>'; }
public function actionInterviewSelected() { if (isset($_POST) && isset($_POST['stu_job_id']) && !empty($_POST['stu_job_id'])) { $interviewCancelForm = new InterviewCancelForm(InterviewCancelForm::TYPE_EMP); //$interviewCancelForm->attributes=$_POST['InterviewCancelForm']; $unInteResumes = InterviewStudentJobTitle::getUnInterviewResumes($_POST['stu_job_id'], Yii::app()->user->id); if (count($unInteResumes) > 0) { try { if (InterviewStudentJobTitle::saveInterviewResumes($unInteResumes, Yii::app()->user->id, $_POST['interviewDate'])) { echo "I am here "; $interviewCancelForm->sendIn(); echo "I am here after send"; $this->renderPartial('/common/_alerts', array('type' => 'success', 'msg' => Yii::t('app', 'msg.success.interview_resumes'))); } echo CHtml::hiddenField('interviewed-date', $_POST['interviewDate']); } catch (Exception $e) { $this->renderPartial('/common/_alerts', array('type' => 'danger', 'msg' => Yii::t('app', 'msg.error.interview_resumes'))); } echo CHtml::hiddenField('interviewed-resumes', implode(',', $unInteResumes)); } else { $this->renderPartial('/common/_alerts', array('type' => 'warning', 'msg' => Yii::t('app', 'msg.alert.no_interview_resumes'))); } } else { $this->renderPartial('/common/_alerts', array('type' => 'danger', 'msg' => Yii::t('app', 'msg.error.resumes_not_found'))); } }
/** * Initializes the menu widget. * This method mainly normalizes the {@link items} property. * If this method is overridden, make sure the parent implementation is invoked. */ public function init() { echo CHtml::openTag('div', array("id" => "divsearch")); echo CHtml::tag("input", array("id" => "searchtext", "type" => "text")); echo CHtml::openTag("button", array("id" => "searchbutton", "class" => "btn btn-primary")); echo "Cari"; echo CHtml::closeTag('button'); echo CHtml::closeTag('div'); echo CHtml::openTag('div', array("id" => "clocationmap", "style" => "height:" . $this->height)) . "\n"; echo CHtml::closeTag('div'); $randNumber = rand(0, 100000); $className = get_class($this->model); echo CHtml::hiddenField($className . "[" . $this->latId . "]", $this->model->latitude, array("class" => "lat_" . $randNumber)); echo CHtml::hiddenField($className . "[" . $this->lonId . "]", $this->model->longitude, array("class" => "lon_" . $randNumber)); echo CHtml::openTag('script', array("src" => "https://maps.googleapis.com/maps/api/js?key=AIzaSyAtc_4SE2BhMel6_WVpSBAjAeF1iczXUow&sensor=false")) . "\n"; echo CHtml::closeTag('script'); echo CHtml::openTag('style'); echo "#clocationmap img { max-width: none; }\n\t\t\t#divsearch { text-align : right }\n\t\t\t#divsearch input { margin : 5px }"; echo CHtml::closeTag('style'); ob_start(); include "picker.js"; $picker = ob_get_clean(); echo CHtml::openTag('script'); echo $picker; echo CHtml::closeTag('script'); //Yii::app()->getClientScript()->registerScript('CLocationPicker',$picker); }
/** * Renders the content of the portlet. */ public function run() { $shortTextTpl = '<span class="short-text" title="Click to view">%s</span>'; $fullTextTpl = '<span class="full-text hide">%s</span>'; Yii::app()->clientScript->registerScript('short-text-widget', "\n\t\t\t\$('body').on('click', '.short-text', function() {\n\t\t\t\t\$(this).hide();\n\t\t\t\t\$(this).siblings('.full-text').removeClass('hide');\n\t\t\t\t\$.get(\$(this).siblings('.short-text-url').val());\n\t\t\t});\n\t\t"); echo sprintf($shortTextTpl, InputHelper::stripoff($this->text, 4)) . sprintf($fullTextTpl, $this->text) . CHtml::hiddenField('', $this->urlOnCLick, array('class' => 'short-text-url')); }
function autoComplete($name, $complete_view, $id = '', $value = '') { $url = is_array($complete_view) ? $complete_view : array($complete_view); $dom_id = CHtml::getIdByName($name); echo CHtml::hiddenField($name, $id, array('id' => $dom_id)); $this->widget('zii.widgets.jui.CJuiAutoComplete', array('name' => $dom_id . '_autocomplete', 'sourceUrl' => $url, 'options' => array('select' => "js:function(event, ui) {\n \$('#{$dom_id}').val(ui.item.id);\n }"), 'value' => $value)); }
/** * Runs the widget and displays the input field */ public function run() { list($name, $id) = $this->resolveNameID(); $htmlOptions = $this->htmlOptions; $htmlOptions['id'] = $id; if (!isset($htmlOptions['class'])) { $htmlOptions['class'] = $this->containerClass; } if ($this->hasModel()) { $value = $this->model->{$this->attribute}; } else { $value = $this->value; } if ($value instanceof Traversable) { $value = (array) $value; } if (!is_array($value)) { $value = array(); } echo CHtml::openTag($this->tagName, $htmlOptions); echo CHtml::hiddenField($name, ""); echo $this->renderArray($value, $name); echo CHtml::closeTag($this->tagName); $baseUrl = Yii::app()->assetManager->publish(__DIR__ . "/assets"); Yii::app()->clientScript->registerScriptFile($baseUrl . "/AArrayInputWidget.js"); $script = "jQuery('#{$id}').arrayInputWidget()"; Yii::app()->clientScript->registerScript(get_class($this) . "#" . $id, $script); }
/** * Run this widget. * This method registers necessary javascript and renders the needed HTML code. */ public function run() { list($name, $id) = $this->resolveNameID(); if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $this->htmlOptions['id'] = $id; } if (isset($this->htmlOptions['name'])) { $name = $this->htmlOptions['name']; } else { $this->htmlOptions['name'] = $name; } if ($this->hasModel() === false && $this->value !== null) { $this->options['value'] = $this->value; } if ($this->hasModel()) { echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::hiddenField($name, $this->value, $this->htmlOptions); } $idHidden = $this->htmlOptions['id']; $nameHidden = $this->htmlOptions['name']; $this->htmlOptions['id'] = $idHidden . '_slider'; $this->htmlOptions['name'] = $nameHidden . '_slider'; echo CHtml::openTag($this->tagName, $this->htmlOptions); echo CHtml::closeTag($this->tagName); $this->options[$this->event] = 'js:function(event, ui) { jQuery(\'#' . $idHidden . '\').val(ui.value); }'; $options = empty($this->options) ? '' : CJavaScript::encode($this->options); $js = "jQuery('#{$id}_slider').slider({$options});\n"; Yii::app()->getClientScript()->registerScript(__CLASS__ . '#' . $id, $js); }
public function renderCheckoutForm(Payment $payment, Order $order, $return = false) { $settings = $payment->getPaymentSystemSettings(); $mrhLogin = $settings['login']; $mrhPass1 = $settings['password1']; $culture = $settings['language']; $invId = $order->id; $invDesc = Yii::t('RobokassaModule.robokassa', 'Payment order #{id} on "{site}" website', ['{id}' => $order->id, '{site}' => Yii::app()->getModule('yupe')->siteName]); $outSum = Yii::app()->money->convert($order->getTotalPrice(), $payment->currency_id); $crc = md5("{$mrhLogin}:{$outSum}:{$invId}:{$mrhPass1}"); $form = CHtml::form($settings['testmode'] ? "http://test.robokassa.ru/Index.aspx" : "https://merchant.roboxchange.com/Index.aspx"); $form .= CHtml::hiddenField('MrchLogin', $mrhLogin); $form .= CHtml::hiddenField('OutSum', $outSum); $form .= CHtml::hiddenField('InvId', $invId); $form .= CHtml::hiddenField('Desc', $invDesc); $form .= CHtml::hiddenField('SignatureValue', $crc); $form .= CHtml::hiddenField('Culture', $culture); $form .= CHtml::submitButton(Yii::t('RobokassaModule.robokassa', 'Pay')); $form .= CHtml::endForm(); if ($return) { return $form; } else { echo $form; } }
function showsaveform() { //Show 'SAVE FORM' only when click the 'Save so far' button the first time, or when duplicate is found on SAVE FORM. global $errormsg, $thissurvey, $surveyid, $clang, $clienttoken, $thisstep; $redata = compact(array_keys(get_defined_vars())); $sTemplatePath = $_SESSION['survey_' . $surveyid]['templatepath']; sendCacheHeaders(); doHeader(); echo templatereplace(file_get_contents($sTemplatePath . "startpage.pstpl"), array(), $redata); echo "\n\n<!-- JAVASCRIPT FOR CONDITIONAL QUESTIONS -->\n" . "\t<script type='text/javascript'>\n" . "\t<!--\n" . "function checkconditions(value, name, type, evt_type)\n" . "\t{\n" . "\t}\n" . "\t//-->\n" . "\t</script>\n\n"; echo CHtml::form(array("/survey/index"), 'post') . "\n"; //PRESENT OPTIONS SCREEN if (isset($errormsg) && $errormsg != "") { $errormsg .= "<p>" . $clang->gT("Please try again.") . "</p>"; } echo templatereplace(file_get_contents($sTemplatePath . "save.pstpl"), array(), $redata); //END echo "<input type='hidden' name='sid' value='{$surveyid}' />\n"; echo "<input type='hidden' name='thisstep' value='{$thisstep}' />\n"; echo CHtml::hiddenField('token', $clienttoken) . "\n"; echo "<input type='hidden' name='saveprompt' value='Y' />\n"; echo "</form>"; echo templatereplace(file_get_contents($sTemplatePath . "endpage.pstpl"), array(), $redata); echo "</html>\n"; exit; }
/** * Renders the input file field */ public function renderField() { list($name, $id) = $this->resolveNameID(); TbArray::defaultValue('id', $id, $this->htmlOptions); TbArray::defaultValue('name', $name, $this->htmlOptions); TbHtml::addCssClass('bfh-selectbox', $this->wrapperOptions); echo CHtml::openTag('div', $this->wrapperOptions); if ($this->hasModel()) { echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions); $value = $this->model->{$this->attribute}; $valueText = $value && isset($this->data[$value]) ? $this->data[$value] : ' '; } else { echo CHtml::hiddenField($name, $this->value, $this->htmlOptions); $value = $this->value; $valueText = $value && isset($this->data[$value]) ? $this->data[$value] : ' '; } echo CHtml::openTag('a', array('class' => 'bfh-selectbox-toggle', 'role' => 'button', 'data-toggle' => 'bfh-selectbox', 'href' => '#')); echo CHtml::tag('span', array('class' => 'bfh-selectbox-option ' . $this->size, 'data-option' => $value), $valueText); echo CHtml::tag('b', array('class' => 'caret'), ' '); echo CHtml::closeTag('a'); echo CHtml::openTag('div', array('class' => 'bfh-selectbox-options')); if ($this->displayFilter) { echo '<input type="text" class="bfh-selectbox-filter">'; } $items = array(); foreach ($this->data as $key => $item) { $items[] = CHtml::tag('a', array('tabindex' => '-1', 'href' => '#', 'data-option' => $key), $item); } echo CHtml::tag('ul', array('role' => 'options'), '<li>' . implode('</li><li>', $items) . '</li>'); echo CHtml::closeTag('div'); echo CHtml::closeTag('div'); }
public function init() { $assets = Yii::app()->getAssetManager()->publish(dirname(__FILE__) . '/assets'); if (!isset($this->htmlOptions['id'])) { $this->htmlOptions['id'] = $this->getId(); } $this->id = $id = $this->htmlOptions['id']; echo CHtml::image($this->url, $this->alt, $this->htmlOptions); if (!empty($this->buttons)) { echo '<div class="jcrop-buttons">' . CHtml::button($this->buttons['start']['label'], $this->getHtmlOptions('start', 'inline')); echo CHtml::button($this->buttons['crop']['label'], $this->getHtmlOptions('crop')); echo CHtml::button($this->buttons['cancel']['label'], $this->getHtmlOptions('cancel')) . '</div>'; } echo CHtml::hiddenField($id . '_x', 0, array('class' => 'coords')); echo CHtml::hiddenField($id . '_y', 0, array('class' => 'coords')); echo CHtml::hiddenField($id . '_w', 0, array('class' => 'coords')); echo CHtml::hiddenField($id . '_h', 0, array('class' => 'coords')); echo CHtml::hiddenField($id . '_x2', 0, array('class' => 'coords')); echo CHtml::hiddenField($id . '_y2', 0, array('class' => 'coords')); $cls = Yii::app()->getClientScript(); $cls->registerScriptFile($assets . '/js/jquery.Jcrop.min.js'); $cls->registerScriptFile($assets . '/js/ejcrop.js', CClientScript::POS_HEAD); $cls->registerCssFile($assets . '/css/jquery.Jcrop.css'); $this->options['onChange'] = "js:function(c) {ejcrop_getCoords(c,'{$id}'); ejcrop_showThumb(c,'{$id}');}"; $this->options['ajaxUrl'] = $this->ajaxUrl; $this->options['ajaxParams'] = $this->ajaxParams; $options = CJavaScript::encode($this->options); if (!empty($this->buttons)) { $js = "ejcrop_initWithButtons('{$id}', {$options});"; } else { $js = "jQuery('#{$id}').Jcrop({$options});"; } $cls->registerScript(__CLASS__ . '#' . $id, $js, CClientScript::POS_READY); }
/** * ### .run() * * Widget's run function */ public function run() { list($name, $id) = $this->resolveNameID(); $this->registerClientScript($id); $this->htmlOptions['id'] = $id; $this->htmlOptions['readonly'] = "readonly"; $radius = $this->displayInput ? "" : "border-radius:4px;"; // Do we have a model? echo '<div class="input-append color" data-color="' . $this->value . '" data-color-format="rgb" id="' . $id . '_color">'; if ($this->hasModel()) { if ($this->form) { if ($this->displayInput) { echo $this->form->textField($this->model, $this->attribute, $this->htmlOptions); } else { echo $this->form->hiddenField($this->model, $this->attribute, $this->htmlOptions); } } else { if ($this->displayInput) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions); } } } else { if ($this->displayInput) { echo CHtml::textField($name, $this->value, $this->htmlOptions); } else { echo CHtml::hiddenField($name, $this->value, $this->htmlOptions); } } echo '<span class="add-on" style="' . $radius . '"><i style="background-color: ' . $this->value . '"></i></span></div>'; }
public function run() { //begin form echo CHtml::beginForm($this->action, $this->method, array('id' => $this->id, 'enctype' => $this->enctype, 'class' => $this->class)); foreach ($this->model as $item) { if ($this->selector) { echo CHtml::checkBox('selector_' . $item['key']); } $name = Awecms::generateFriendlyName($item["key"]); ?> <div class="settings row"> <?php echo $this->getlabel($item['key']); switch ($item['type']) { //add new types here case 'textfield': echo $this->getFullTextField($item); break; case 'boolean': echo CHtml::hiddenField($item['key'], 0); echo CHtml::checkBox($item['key'], $item['value']); break; case 'image_url': echo $this->getFullTextField($item); echo "<a class=\"right\" href=\"{$item["value"]}\" target=\"_blank\"><img src=\"{$item["value"]}\" title=\"{$name}\" alt=\"{$name}\" /></a>"; break; case 'email': echo $this->getFullTextField($item); break; case 'textarea': echo CHtml::textArea($item['key'], $item['value']); case 'NULL': break; default: echo "Unsupported type: " . $item['type'] . " of " . $item['key'] . " with value " . $item['value'] . "<br/>"; break; } if (isset($item['hint'])) { ?> <p class="hint"> <?php echo $item['hint']; ?> </p> <?php } ?> </div> <?php } ?> <div class="row buttons"> <?php echo CHtml::submitButton('Submit!'); ?> </div> <?php echo CHtml::endForm(); }
public function renderLink($field, array $htmlOptions = array()) { $fieldName = $field->fieldName; $linkId = ''; $name = ''; $linkSource = null; // TODO: move this code and duplicate code in X2Model::renderModelInput into a helper // method. Might be able to use X2Model::getLinkedModel. if (class_exists($field->linkType)) { if (!empty($this->owner->{$fieldName})) { list($name, $linkId) = Fields::nameAndId($this->owner->{$fieldName}); $linkModel = X2Model::getLinkedModelMock($field->linkType, $name, $linkId, true); } else { $linkModel = X2Model::model($field->linkType); } if ($linkModel instanceof X2Model && $linkModel->asa('X2LinkableBehavior') instanceof X2LinkableBehavior) { $linkSource = Yii::app()->controller->createAbsoluteUrl($linkModel->autoCompleteSource); $linkId = $linkModel->id; $oldLinkFieldVal = $this->owner->{$fieldName}; $this->owner->{$fieldName} = $name; } } $input = CHtml::hiddenField($field->modelName . '[' . $fieldName . '_id]', $linkId, array()); $input .= CHtml::activeTextField($this->owner, $field->fieldName, array_merge(array('title' => $field->attributeLabel, 'data-x2-link-source' => $linkSource, 'class' => 'x2-mobile-autocomplete', 'autocomplete' => 'off'), $htmlOptions)); return $input; }
public function run() { list($name, $id) = $this->resolveNameID(); if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $this->htmlOptions['id'] = $id; } if (isset($this->htmlOptions['name'])) { $name = $this->htmlOptions['name']; } if ($this->flat === false) { if ($this->hasModel()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } } else { if ($this->hasModel()) { echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions); $attribute = $this->attribute; $this->options['defaultDate'] = $this->model->{$attribute}; } else { echo CHtml::hiddenField($name, $this->value, $this->htmlOptions); $this->options['defaultDate'] = $this->value; } if (!isset($this->options['onSelect'])) { $this->options['onSelect'] = "js:function( selectedDate ) { jQuery('#{$id}').val(selectedDate);}"; } $id = $this->htmlOptions['id'] = $id . '_container'; $this->htmlOptions['name'] = $name . '_container'; echo CHtml::tag('div', $this->htmlOptions, ''); } $this->options['beforeShowDay'] = <<<EOD js:function(date){ \tif (typeof reservedDays !== 'undefined') { \t\tfor (i = 0; i < reservedDays.length; i++) { \t\t\tif (date.getFullYear() == reservedDays[i][0] && date.getMonth() == reservedDays[i][1] - 1 && date.getDate() == reservedDays[i][2]) \t\t\t{ \t\t\t\treturn [false, "datepicker-calendarDescriptionReserved"]; \t\t\t} \t\t} \t\treturn [true,""]; \t} } EOD; $options = CJavaScript::encode($this->options); $js = "jQuery('#{$id}').datepicker({$options});"; if ($this->language != '' && $this->language != 'en') { $this->registerScriptFile($this->i18nScriptFile); $js = "jQuery('#{$id}').datepicker(jQuery.extend({showMonthAfterYear:false}, jQuery.datepicker.regional['{$this->language}'], {$options}));"; } $cs = Yii::app()->getClientScript(); if (isset($this->defaultOptions)) { $this->registerScriptFile($this->i18nScriptFile); $cs->registerScript(__CLASS__, $this->defaultOptions !== null ? 'jQuery.datepicker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : ''); } $cs->registerScript(__CLASS__ . '#' . $id, $js); }
/** * Renders the widget. */ public function run() { if ($this->hidden) { echo CHtml::hiddenField($this->getId(), $this->defaultValue, $this->htmlOptions); } else { echo CHtml::textField($this->getId(), $this->defaultValue, $this->htmlOptions); } }
public function display(array $attr = null) { if ($this->_value != "") { CHtml::hiddenField($this->_name, $this->_value); } else { CHtml::activeHiddenField($this->_name, $this->_model); } }
/** * Renders the select2 field */ public function renderField() { if ($this->hasModel()) { echo $this->asDropDownList ? \CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->options) : \CHtml::activeHiddenField($this->model, $this->attribute); } else { echo $this->asDropDownList ? \CHtml::dropDownList($this->options['name'], $this->value, $this->data, $this->options) : \CHtml::hiddenField($this->options['name'], $this->value); } }
public function renderSection() { echo CHtml::openTag('section', array('id' => 'main')); echo CHtml::tag('textarea', array('id' => 'in'), $this->model->content); echo CHtml::tag('div', array('id' => 'out', 'class' => 'markdown-body'), ''); echo CHtml::closeTag('section'); echo CHtml::hiddenField('help_id', $this->model->id); }
function form($name, $label, $action, $dis = array()) { echo CHtml::beginForm('', 'POST'); echo CHtml::submitButton($label, $dis + array('style' => 'float: left')); echo CHtml::hiddenField('action', $action); echo CHtml::hiddenField('name', $name); echo CHtml::endForm(); }
public function run() { list($name, $id) = $this->resolveNameID(); if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $this->htmlOptions['id'] = $id; } if (isset($this->htmlOptions['name'])) { $name = $this->htmlOptions['name']; } else { $this->htmlOptions['name'] = $name; } $contHtmlOptions = $this->htmlOptions; $contHtmlOptions['id'] = $id . 'container'; echo CHtml::openTag('div', $contHtmlOptions); $inputOptions = array('id' => $id); if ($this->hasModel()) { echo CHtml::activeHiddenField($this->model, $this->attribute, $inputOptions); $imgPath = $this->model->{$this->attribute}; } else { echo CHtml::hiddenField($name, $this->value, $inputOptions); $imgPath = $this->value; } if (!@getimagesize($imgPath)) { $imgPath = $this->assetsDir . '/images/no-photo.gif'; } echo CHtml::image($imgPath, 'preview', array('id' => 'image-preview-' . $id, 'style' => 'max-width: 120px; max-height: 120px; display: block; margin-bottom: 10px;')); echo CHtml::button('Browse', array('id' => $id . 'browse', 'class' => 'btn')); echo CHtml::closeTag('div'); $settings = array_merge(array('places' => "", 'rememberLastDir' => false), $this->settings); $settings['dialog'] = array('zIndex' => 400001, 'width' => 900, 'modal' => true, 'title' => "Files"); $settings['editorCallback'] = 'js:function(url) { $(\'#\'+aFieldId).attr(\'value\',url); $(\'#image-preview-\'+aFieldId).attr(\'src\',url); }'; $settings['closeOnEditorCallback'] = true; $connectorUrl = CJavaScript::encode($this->settings['url']); $settings = CJavaScript::encode($settings); $script = <<<EOD window.elfinderBrowse = function(field_id, connector) { var aFieldId = field_id, aWin = this; if(\$("#elFinderBrowser").length == 0) { \$("body").append(\$("<div/>").attr("id", "elFinderBrowser")); var settings = {$settings}; settings["url"] = connector; \$("#elFinderBrowser").elfinder(settings); } else { \$("#elFinderBrowser").elfinder("open", connector); } } EOD; $cs = Yii::app()->getClientScript(); $cs->registerScript('ServerFileInput#global', $script); $js = '$("#' . $id . 'browse").click(function(){window.elfinderBrowse("' . $id . '", ' . $connectorUrl . ')});'; $cs->registerScript('ServerFileInput#' . $id, $js); }
public function run() { if ($this->selector == null) { list($this->name, $this->id) = $this->resolveNameId(); $this->selector = '#' . $this->id; if (isset($this->htmlOptions['placeholder'])) { $this->options['placeholder'] = $this->htmlOptions['placeholder']; } if (!isset($this->htmlOptions['multiple'])) { $data = array(); if (isset($this->options['placeholder'])) { $data[''] = ''; } $this->data = $data + $this->data; } if ($this->hasModel()) { if (isset($this->options['ajax'])) { echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::activeDropDownList($this->model, $this->attribute, $this->data, $this->htmlOptions); } } elseif (!isset($this->options['ajax'])) { $this->htmlOptions['id'] = $this->id; echo CHtml::dropDownList($this->name, $this->value, $this->data, $this->htmlOptions); } else { echo CHtml::hiddenField($this->name, $this->value, $this->htmlOptions); } } $bu = Yii::app()->assetManager->publish(dirname(__FILE__) . '/assets/'); $cs = Yii::app()->clientScript; //$cs->registerCssFile($bu . '/select2.css'); if (YII_DEBUG) { $cs->registerScriptFile($bu . '/select2.js'); } else { $cs->registerScriptFile($bu . '/select2.min.js'); } if ($this->sortable) { $cs->registerCoreScript('jquery.ui'); } $options = CJavaScript::encode(CMap::mergeArray($this->defaultOptions, $this->options)); ob_start(); echo "jQuery('{$this->selector}').select2({$options})"; foreach ($this->events as $event => $handler) { echo ".on('{$event}', " . CJavaScript::encode($handler) . ")"; } echo ';'; if ($this->sortable) { echo <<<JavaScript jQuery('{$this->selector}').select2("container").find("ul.select2-choices").sortable({ \tcontainment: 'parent', \tstart: function() { jQuery('{$this->selector}').select2("onSortStart"); }, \tupdate: function() { jQuery('{$this->selector}').select2("onSortEnd"); } }); JavaScript; } $cs->registerScript(__CLASS__ . '#' . $this->id, ob_get_clean()); }
/** * Render the form begin and add the hidden fields */ protected function renderBeginForm() { $this->formOptions['htmlOptions']['id'] = EMBConst::FORMID; $this->formOptions['htmlOptions']['enctype'] = 'multipart/form-data'; //because of menu import $this->_form = $this->controller->beginWidget($this->formClass, $this->formOptions); $nestedConfig = $this->itemsProvider->nestedConfig; echo CHtml::hiddenField(EMBConst::HIDDENNAME_NESTEDCONFIG, $nestedConfig, array('id' => EMBConst::HIDDENNAME_NESTEDCONFIG)); echo CHtml::hiddenField(EMBConst::HIDDENNAME_EDITITEM, '', array('id' => EMBConst::HIDDENNAME_EDITITEM)); }
/** * Run this widget. * This method registers necessary javascript and renders the needed HTML code. */ public function run() { list($name, $id) = $this->resolveNameID(); if (isset($this->htmlOptions['id'])) { $id = $this->htmlOptions['id']; } else { $this->htmlOptions['id'] = $id; } if (isset($this->htmlOptions['name'])) { $name = $this->htmlOptions['name']; } if ($this->flat === false) { if ($this->hasModel()) { echo CHtml::activeTextField($this->model, $this->attribute, $this->htmlOptions); } else { echo CHtml::textField($name, $this->value, $this->htmlOptions); } } else { if ($this->hasModel()) { echo CHtml::activeHiddenField($this->model, $this->attribute, $this->htmlOptions); $attribute = $this->attribute; $this->options['defaultDate'] = $this->model->{$attribute}; } else { echo CHtml::hiddenField($name, $this->value, $this->htmlOptions); $this->options['defaultDate'] = $this->value; } $this->options['altField'] = '#' . $id; $id = $this->htmlOptions['id'] = $id . '_container'; $this->htmlOptions['name'] = $name . '_container'; echo CHtml::tag('div', $this->htmlOptions, ''); } $options = CJavaScript::encode($this->options); $js = "jQuery('#{$id}').datetimepicker({$options});"; $assetsDir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets'; $assets = Yii::app()->assetManager->publish($assetsDir); $i18nScriptFile = 'jquery-ui-timepicker-' . $this->language . '.js'; $i18nScriptPath = $assetsDir . DIRECTORY_SEPARATOR . 'localization' . DIRECTORY_SEPARATOR . $i18nScriptFile; $cs = Yii::app()->clientScript; $cs->registerScriptFile($assets . '/jquery-ui-timepicker-addon.js', CClientScript::POS_END); if ($this->language != '' && $this->language != 'en') { $this->registerScriptFile($this->i18nScriptFile); if (file_exists($i18nScriptPath)) { $cs->registerScriptFile($assets . '/localization/' . $i18nScriptFile, CClientScript::POS_END); } $js = "jQuery('#{$id}').datetimepicker(jQuery.extend(jQuery.datepicker.regional['{$this->language}'], {$options}));"; } if (isset($this->defaultOptions)) { $this->registerScriptFile($this->i18nScriptFile); if (file_exists($i18nScriptPath)) { $cs->registerScriptFile($assets . '/localization/' . $i18nScriptFile, CClientScript::POS_END); } $cs->registerScript(__CLASS__, $this->defaultOptions !== null ? 'jQuery.datetimepicker.setDefaults(' . CJavaScript::encode($this->defaultOptions) . ');' : ''); } $cs->registerScript(__CLASS__ . '#' . $id, $js); }
public function renderCsvButton() { echo CHtml::beginForm(array('//user/csv/select')); foreach ($this->columns as $column) { if (isset($column->name)) { echo CHtml::hiddenField($column->name, $column->value); } } printf('<td>%s</td>', CHtml::submitButton('CSV')); echo CHtml::endForm(); }
public function run() { // here render procedures echo CHtml::beginForm($this->action, $this->method, array('id' => $this->id, 'enctype' => $this->enctype, 'target' => $this->target)); // you better create a function but // for the sake of the example... foreach ($this->attributes as $attr) { // here we can actually say i // this is very simple but you get the idea echo CHtml::label($attr['label'], $attr['name']); if ($attr['type'] == 'text') { echo CHtml::textField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']); } else { if ($attr['type'] == 'textarea') { echo CHtml::textArea($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']); } else { if ($attr['type'] == 'password') { echo CHtml::passwordField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']); } else { if ($attr['type'] == 'checkbox') { echo CHtml::checkBox($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'checkboxlist') { echo CHtml::checkBoxList($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'date') { echo CHtml::dateField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['htmlOptions']); } else { if ($attr['type'] == 'dropdownlist') { echo CHtml::dropDownList($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'file') { echo CHtml::fileField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'hidden') { echo CHtml::hiddenField($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'radio') { echo CHtml::radioButton($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['items'], $attr['htmlOptions']); } else { if ($attr['type'] == 'radiolist') { echo CHtml::radioButtonList($this->model_name . '[' . $this->category . ']' . '[' . $attr['name'] . ']', $attr['value'], $attr['items'], $attr['htmlOptions']); } } } } } } } } } } } // do more here } echo "<br/><br/><div class='row-fluid'>"; echo CHtml::submitButton($this->submit['label'], $this->submit['options']); echo "</div>"; echo CHtml::endForm(); }