Yii Framework Forum: Yii 使用中文,必填项为什么怎么不显示红色星号? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii 使用中文,必填项为什么怎么不显示红色星号? Rate Topic: -----

#1 User is offline   javad78 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 11
  • Joined: 03-December 10

Posted 31 December 2012 - 05:48 AM

比如这段代码

<div class="row">
<?php echo $form->labelEx($model,'姓名'); ?>
<?php echo $form->textField($model,'name'); ?>
<?php echo $form->error($model,'name'); ?>
</div>

<div class="row">
<?php echo $form->labelEx($model,'email'); ?>
<?php echo $form->textField($model,'email'); ?>
<?php echo $form->error($model,'email'); ?>
</div>

“姓名”栏后面就没有红色星号,而 email 栏后面就显示红色星号,奇怪了!
0

#2 User is offline   hiscaler 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 229
  • Joined: 17-October 09

Posted 04 January 2013 - 01:36 AM

请提供一下 Model rules 设定
0

#3 User is offline   包菜兄 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 23-October 12

Posted 04 January 2013 - 02:44 AM

<?php echo $form->labelEx($model,'姓名'); ?> 这里的 姓名 不要自己改。要用字段名。
前两天就吃亏了。然后在rules 里面吧 名字的字段设置为 required 就有了。不要忘记用labelEx 想要用中文。就在model 中的
public function attributeLabels()
{
return array(
'字段名'=>'汉字',
);
}

我想我没有记错的话。。。
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users