<div class="row"> <?php foreach($template_fields as $key=>$item){?> <input type="hidden" id="template_<?php echo $item['id']?>" name="template_fields_ids[]" value="<?php echo $item['id']?>"/> <input type="hidden" id="template_id" name="template_id" value="<?php echo $item['template_id']?>"/> <?php echo Widget::factory('Product_Tpl_Data', array('tpl_field_orm' => $item)); ?> <?php }?> </div> //.....Product_Tpl_Datal.php中内容widget/product/tpl/text.phpclass Widget_Product_Tpl_Data extends Widget { /** * 视图名称 * * @var string */ protected $_view_name = 'widget/product/tpl/input'; /** * 控件属性 * * @var array */ protected $_data = array(); /** * 渲染前置回调 * * @return void */ protected function _render_before() { $tpl_field_orm = Arr::get($this->_data,'tpl_field_orm'); $field_types = Kohana::config('channel.field_types'); $field_type = Arr::get($field_types,$tpl_field_orm['field_type']); $this->_view_name = 'widget/product/tpl/' . $field_type; } }
//.....<div class="form-group"> <?php if($tpl_field_orm['is_required'] ==1){?> <label class="col-md-2 control-label"><span class="required">*</span><?php echo $tpl_field_orm['field_name']?></label> <?php }else{?> <label class="col-md-2 control-label"><?php echo $tpl_field_orm['field_name']?></label> <?php }?> <div class="col-md-10"> <?php if($tpl_field_orm['is_required'] ==1){?> <input class="form-control required " οnblur="checkText(this)" minlength_self="<?php echo $tpl_field_orm['min_length']?>" maxlength_self="<?php echo $tpl_field_orm['max_length']?>" id="text_<?php echo $tpl_field_orm['id']?>" name="text_<?php echo $tpl_field_orm['id']?>" value="<?php echo str_replace("\"",""",$tpl_field_orm['default_value']);?>"/> <?php }else{?> <input class="form-control " οnblur="checkText(this)" minlength_self="<?php echo $tpl_field_orm['min_length']?>" maxlength_self="<?php echo $tpl_field_orm['max_length']?>" id="text_<?php echo $tpl_field_orm['id']?>" name="text_<?php echo $tpl_field_orm['id']?>" value="<?php echo str_replace("\"",""",$tpl_field_orm['default_value']);?>"/> <?php }?> <span class="help-block"> <?php echo $tpl_field_orm['fill_hint']?> </span> </div> </div>
php kahana widget
最新推荐文章于 2020-01-10 21:04:47 发布