1

I want to add birthdate from frontend form using datepicker

phtml code:

<div class="field">
    <label class="required" for="birthday"><em>*</em><?php echo $this->__('Date of birth');?></label>
    <div class="input-box">
        <input type="text" class="input-text required-entry" title="Birthday" id="birthday" name="birthday" value="" style="  float: left;margin-right: 7px;max-width: 150px;">
        <img  title="Select Date" id="date" class="v-middle" alt="" src="<?php echo $this->getSkinUrl("images/calendar.gif");?> "/>
        <script type="text/javascript">
        //<![CDATA[
            Calendar.setup({
                inputField: "birthday",
                ifFormat: "%m/%e/%Y",
                showsTime: false,
                button: "date",
                align: "Bl",
                singleClick : true
                });
            //]]>
        </script>
    </div>
</div>

save data

    $data = $this->getRequest()->getPost();
    $post_data = $this->_filterDates($post_data, array('birthdate', 'expiry_date'));
    $student = Mage::getModel('school/student');
    $student->setData($data);
    $student->save();   

in $data i m getting date like this 05/7/2015 but in database this date is not saved. it saved default value. how can i save date from frontend?

0

First, you should clear the cache. Even if the cache is disabled the table schemas are cached and your field might not be recognized when calling DESCRIBE TABLE in order to match the data to the table columns.
Second, you should take a look at how $student->getData() looks like before calling $student->save(). See if your birthdate field exists and take a look at the value it has.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.