Magento:如何将出生日期的3输入更改为1输入出生日期。格式化日期dd / mm / yyy

时间:2015-02-05 10:58:38

标签: php magento date

我有一个问题,就像最重要的问题一样。 这是我的代码:

<?php
$this->setDateInput('d',
    '<div class="dob-day">
         <input type="text" id="' . $this->getFieldId('day') . '" name="' . $this->getFieldName('day') . '" value="' . $this->getDay() . '" title="' . $this->__('Day') . '" class="input-text validate-custom" ' . $this->getFieldParams() . ' />
         <label for="' . $this->getFieldId('day') . '">' . $this->__('DD') . '</label>
     </div>'
);

$this->setDateInput('m',
    '<div class="dob-month">
         <input type="text" id="' . $this->getFieldId('month') . '" name="' . $this->getFieldName('month') . '" value="' . $this->getMonth()  . '" title="' . $this->__('Month')  . '" class="input-text validate-custom" ' . $this->getFieldParams()  . ' />
         <label for="' . $this->getFieldId('month') . '">' . $this->__('MM')  . '</label>
     </div>'
);

$this->setDateInput('y',
    '<div class="dob-year">
         <input type="text" id="' . $this->getFieldId('year') . '" name="' . $this->getFieldName('year') . '" value="' . $this->getYear()  . '" title="' . $this->__('Year')  . '" class="input-text validate-custom" ' . $this->getFieldParams()  . ' />
         <label for="' . $this->getFieldId('year') . '">' . $this->__('YYYY')  . '</label>
     </div>'
);

&GT;

我有3个输入,但他想成为一个并保存出生日期。你有什么想法吗?

1 个答案:

答案 0 :(得分:1)

转到app / design / frontend / your_package / your_theme / template / customer / widget

你的dob.phtml看起来像这样

<label for="<?php echo $this->getFieldId('month')?>" class="required"><em>*</em><?php echo $this->__('Date of Birth') ?></label>
<div class="input-box customer-dob">
<?php
    if($this->getMonth()=="" || $this->getDay()=="" || $this->getYear()=="")
    {
      $dob = "";?>
      <div class="dob-full">
        <input type="text" class="datepicker input-text required-entry" id="<?php echo $this->getFieldId('dob')?>" name="<?php echo $this->getFieldName('dob')?>" />
    </div>

    <?php } 
    else
    {
      $dob = $this->getMonth()."/".$this->getDay()."/".$this->getYear();?>
      <div class="dob-full">
        <input type="text" class="input-text required-entry" value="<?php echo $dob ?>" id="<?php echo $this->getFieldId('dob')?>" name="<?php echo $this->getFieldName('dob')?>" disabled />
    </div>

    <?php }

?>
    <?php //echo $this->getSortedDateInputs() ?>

    <div class="validation-advice" style="display:none;"></div>
</div>

<link rel="stylesheet" href="//code.jquery.com/ui/1.11.0/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/ui/1.11.0/jquery-ui.js"></script>
<script type="text/javascript">
//<![CDATA[
    //var customer_dob = new Varien.DOB('.customer-dob', true, '<?php echo $this->getDateFormat() ?>');
//]]>
jQuery(document).ready(function($){
  $( ".datepicker" ).datepicker({
      dateFormat: "m/d/yy",
      changeMonth: true,
      changeYear: true,
      yearRange: '1910:2014'
    });
})
</script>


Note : Please include ui css and js inside your local.xml