本文整理汇总了PHP中CForm::render方法的典型用法代码示例。如果您正苦于以下问题:PHP CForm::render方法的具体用法?PHP CForm::render怎么用?PHP CForm::render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CForm
的用法示例。
在下文中一共展示了CForm::render方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: registerAssignScript
/**
*
* @param CActiveRecord $model
* @param int $id
* @param array $config
*/
public function registerAssignScript($model, $id, array $config = array())
{
Yii::app()->controller->beginWidget('zii.widgets.jui.CJuiDialog', array('id' => 'assignDriver', "options" => array('title' => 'Assign Driver', 'autoOpen' => false, 'modal' => true, 'buttons' => array('Close' => 'js:function(){$(this).dialog("close")}', 'Assign' => 'js:function(){' . CHtml::ajax(array('url' => $config['ajaxUrl'], 'type' => 'post', 'dataType' => 'json', 'data' => 'js:$("#assignDriver form").serialize()', 'success' => 'function(r){if(r.success){
$("#assignDriver").dialog("close");
$.fn.yiiGridView.update("tracking-grid");
};
if(!r.success){alert("Gagal assign driver")}}')) . ';}'))), true);
$driverForm = new CForm(array('elements' => array('driver' => array('type' => 'dropdownlist', 'items' => OrderTracking::getDriverList()), 'id' => array('type' => 'hidden'))), $model);
echo $driverForm->render();
Yii::app()->controller->endWidget();
Yii::app()->clientScript->registerScript($id, "jQuery('body').undelegate('.assignDriver_button','click').delegate('.assignDriver_button','click',function(){\ndriverDialog=jQuery('#assignDriver');\ndriverDialog.dialog('open');\njQuery('#assignDriver input#OrderTracking_id').val(\$(this).attr('rel').replace('grid.',''));\n\treturn false;\n});\t");
}
示例2: run
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->language) {
$this->language = Yii::app()->language;
}
$value = $this->hasModel() ? $this->model->{$this->attribute} : $this->value;
if (!empty($this->config)) {
$vm = new VirtualModel($this->config, 'FieldSet', $value);
$form = new CForm($vm->formMap, $vm);
echo str_replace('VirtualModel_', str_replace(array('[', ']', '-'), '_', $name) . '_', str_replace('VirtualModel[', $name . '[', str_ireplace('</form>', '', preg_replace('/<form([^>]*)>/msi', '', $form->render()))));
}
}
示例3: foreach
class="cms-hidden"<?php
}
?>
>
<?php
$form_array = $FS->validators[$rule];
foreach ($form_array as $_k => $_v) {
$form_array[$_k]['label'] = Yii::t('cms', ucfirst($_k));
if ($checked) {
$form_array[$_k]['default'] = $r[$_k];
}
}
$vm = new VirtualModel($form_array);
$form = new CForm($vm->formMap, $vm);
$newName = $name . '[' . $k . '][rules][' . $i . ']';
echo str_replace('VirtualModel_', str_replace(array('[', ']', '-'), '_', $newName) . '_', str_replace('VirtualModel[', $newName . '[', str_ireplace('</form>', '', preg_replace('/<form([^>]*)>/msi', '', $form->render()))));
?>
</fieldset>
<?php
}
?>
</li>
<?php
$i++;
}
?>
</ul>
</div>
</fieldset>
</div>
示例4: render
public function render()
{
$this->title = null;
$className = get_class($this->getModel(false));
$js = <<<HTML
<script type="text/javascript">
\$(function() {
HTML;
if (is_subclass_of($className, 'I18nActiveRecord')) {
$langs = call_user_func(array($className, 'getLangs'), Yii::app()->language);
$allLangs = call_user_func(array($className, 'getLangs'));
if (!empty($langs)) {
foreach ($this->_config['elements'] as $k => $v) {
if (in_array($k, call_user_func(array($className, 'i18n'))) && is_array($v)) {
$txtButton = Yii::t('languages', $allLangs[Yii::app()->language]);
$js .= <<<JS
fieldset = \$('<div></div>')
.attr('id', '{$this->uniqueId}_field_{$k}')
.insertBefore('#{$this->uniqueId} .field_{$k}');
langbuttons = \$('<span>[</span>')
.attr('id', '{$this->uniqueId}_langbuttons_{$k}')
.addClass('cms-form-langswitcher')
.appendTo(fieldset);
\$('#{$this->uniqueId} .field_{$k}').appendTo(fieldset);
button = \$('<a href="#"></a>')
.text('{$txtButton}')
.addClass('cms-form-langswitcher-active')
.attr('rel', 'field_{$k}')
.click(function(){
\$('#{$this->uniqueId}_field_{$k}').find('div.row').hide();
\$('#{$this->uniqueId} .field_{$k}').show();
\$('#{$this->uniqueId}_langbuttons_{$k} a').removeClass('cms-form-langswitcher-active');
\$(this).addClass('cms-form-langswitcher-active');
\$('#{$this->uniqueId}_langbuttons_{$k}').appendTo('#{$this->uniqueId} .field_{$k} label');
return false;
})
.appendTo(langbuttons);
\$('#{$this->uniqueId}_langbuttons_{$k}').appendTo('#{$this->uniqueId} .field_{$k} label');
JS;
foreach ($langs as $langId => $langName) {
$this->getElements()->add($langId . '_' . $k, $v);
$txtButton = Yii::t('languages', $langName);
$js .= <<<JS
\$('#{$this->uniqueId} .field_{$langId}_{$k}').hide().appendTo(fieldset);
button = \$('<a href="#"></a>')
.text('{$txtButton}')
.attr('rel', 'field_{$langId}_{$k}')
.click(function(){
\$('#{$this->uniqueId}_field_{$k}').find('div.row').hide();
\$('#{$this->uniqueId} .field_{$langId}_{$k}').show();
\$('#{$this->uniqueId}_langbuttons_{$k} a').removeClass('cms-form-langswitcher-active');
\$(this).addClass('cms-form-langswitcher-active');
\$('#{$this->uniqueId}_langbuttons_{$k}').appendTo('#{$this->uniqueId} .field_{$langId}_{$k} label');
return false;
})
.appendTo(langbuttons);
JS;
}
$js .= <<<JS
langbuttons.append(']');
JS;
}
}
}
}
$js .= <<<HTML
});
</script>
HTML;
return parent::render() . $js;
}
示例5: CForm
<ul>
<li>
<?php
echo CHtml::link("General", '#tabs-1');
?>
</li>
<li>
<?php
echo CHtml::link("Access And Security", "#tabs-2");
?>
</li>
</ul>
<div class="form">
<?php
if (Yii::app()->user->hasFlash('updateProfile')) {
?>
<div class="success ui-tabs-panel">
<?php
echo Yii::app()->user->getFlash('updateProfile');
?>
</div>
<?php
}
?>
<?php
$form = new CForm(array('activeForm' => array('enableClientValidation' => 1, 'htmlOptions' => array('enctype' => 'multipart/form-data'), 'clientOptions' => array()), 'showErrorSummary' => 1, 'elements' => array('<div id="tabs-1">', 'tabs-1' => array('type' => 'form', 'title' => 'General', 'elements' => array('firstname' => array('type' => 'text'), 'lastname' => array('type' => 'text'), 'email' => array('type' => 'text'), 'image' => array('type' => 'file'))), '</div>', '<div id="tabs-2">', 'tabs-2' => array('type' => 'form', 'title' => 'Akses dan Keamanan', 'elements' => array('username' => array('type' => 'text', 'disabled' => 'disabled'), 'oldPassword' => array('type' => 'password'), 'newPassword' => array('type' => 'password'), 'confirmPassword' => array('type' => 'password'), '</div>'), 'buttons' => array('<div class="ui-tabs-panel ui-widget-content ui-corner-bottom">', 'Save' => array('type' => 'submit', 'label' => 'Save'))))), $model);
echo $form->render();
?>
</div>
</div>