在我的CakePHP项目中,我想显示错误消息,但它不起作用.
当我提交时,我希望它显示如下错误消息:"此字段是必需的",但默认情况下显示"请填写此字段".我改变了消息,但它没有改变核心.
我的视图,模型和控制器代码如下:
add_district.ctp:
<div class="pg_title txtLeft">Add District</div>
<?php echo $this->Form->create('Admins', array('action' => 'add_district'));?>
<table>
<tbody>
<tr>
<td><label>District Name<span class="red required">*</span></label></td>
<td><?php echo $this->Form->input('District.district_name',array('label'=>false,'div'=>false,'size'=>50,'style'=>'width:330px;')); ?></td>
</tr>
<tr>
<td colspan="2" align="right" style="padding-right: 113px;"><input type="reset" value="Reset"> | <?php echo $this->Form->submit('ADD', array('div' => false));?></td>
</tr>
</tbody>
</table>
<?php print $this->Form->end();?>
<div class="clear"></div>
Run Code Online (Sandbox Code Playgroud)
型号: District.php
<?php
App::uses('AppModel', 'Model');
/**
* Admin Login Model
*
*/
class District extends AppModel
{
public $name='District';
public $usetables='districts';
public $validate = array(
'district_name' => array(
'rule' => …Run Code Online (Sandbox Code Playgroud) 我试图将一个数字转换为小时,分钟.但它不能正常工作.我有变量有价值的东西
$t_hr = 193;
Run Code Online (Sandbox Code Playgroud)
我想像3 hr 13 min
我尝试这段代码一样显示它
$t_min = 193;
if($t_min>60)
{
$t_hr=$t_hr+1;
$t_min = $t_min-60;
}
Run Code Online (Sandbox Code Playgroud)
这不是很好.我需要得到像上面这样的价值.任何想法?