1

我正在尝试将时间字段添加到管理表单,但它不起作用:

    $fieldset->addField('sched_time', 'time', array(
      'label'     => Mage::helper('servicemanager')->__('Scheduled Time'),
      'style'     => 'width:45px',
      'class'     => 'required-entry',
      'required'  => true,
      'name'      => 'sched_time',
      'value'  => '09,00,00',
    ));

问题如下:

  1. 数据未存储在数据库中('sched_time' 是 mysql 时间字段)
  2. “价值”不做任何事情。我需要将默认值设置为 09:00:00(上午 9 点)

参考:http ://www.excellencemagentoblog.com/magento-admin-form-field

4

2 回答 2

1

您需要在控制器的saveAction()方法中手动编写一些代码,如下所示:

public function saveAction(){
    $id = $this->getRequest()->getParam('id');
    $model = Mage::getModel('module/model')->load($id);
    $time = $this->getRequest()->getParam('sched_time');
    $sched_time = $time[0] . ':' . $time[1] . ':' . $time[2]; //HH:MM:SS
    $model->setData('sched_time', $sched_time);
    $model->save();
}

希望这将有助于未来的游客!

于 2014-05-29T09:35:22.777 回答
0

你需要做一个观察者,经过几个小时试图自己找到这个我遇到了这个链接magento weight 属性没有小数点

希望这会有所帮助,因为它帮助了我

于 2013-03-19T17:26:30.553 回答