1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Insert date

Discussion in 'XenForo Development Discussions' started by Mythotical, Aug 6, 2011.

  1. Mythotical

    Mythotical Well-Known Member

    On one of my blocks I need to insert a date that the member adds when making a new event. The problem I run into is that it keeps wanting to enter no date and no id. As well I keep getting this error now since I started using Zend_Date:
    This is the save process page:
    PHP:
    $this->_assertPostOnly();

            
    $dwInput $this->_input->filter(array(
                
    'eid' => XenForo_Input::UINT,
                
    'event_date' => XenForo_Input::UINT,
                
    'event_month' => XenForo_Input::NUM,
                
    'event_day' => XenForo_Input::NUM,
                
    'event_year' => XenForo_Input::NUM,
                
    'event_hour' => XenForo_Input::NUM,
                
    'event_minute' => XenForo_Input::NUM,
                
    'event_message' => XenForo_Input::STRING,
                
    'event_username' => XenForo_Input::STRING
            
    ));

            
    $datearray = array('year' => $dwInput['event_year'],
                           
    'month' => $dwInput['event_month'],
                           
    'day' => $dwInput['event_day'],
                           
    'hour' => $dwInput['event_hour'],
                           
    'minute' => $dwInput['event_minute'],
                           
    'second' => 0);
            
    $date = new Zend_Date($datearray);

            
    $dw XenForo_DataWriter::create('xPortal_DataWriter_Events');
            if (
    $dwInput['eid'])
                
    $dw->setExistingData($dwInput['eid']);
            
            
    $dw->set('eid'$dwInput['eid']);
            
    $dw->set('event_date'$date);
            
    $dw->set('event_message'$dwInput['event_message']);
            
    $dw->set('event_username'$dwInput['event_username']);
            
    $dw->save();
            
            
    $redirectType = ($dwInput['eid'] ?
                
    XenForo_ControllerResponse_Redirect::RESOURCE_UPDATED :
                
    XenForo_ControllerResponse_Redirect::RESOURCE_CREATED);
                
            return 
    $this->responseRedirect(
                
    $redirectType,
                
    XenForo_Link::buildAdminLink('xportal/events')
            );
        }
    Here is my page with the fields:
    HTML:
    <xen:title>xPortal Event :: Add</xen:title>
    
    <div class="selection">
        <h2 class="heading">{xen:phrase xportal_adding_an_event}</h2>
        <div class="sectionContent secondaryContent">
    
            <xen:form action="{xen:adminlink 'xportal/events/save'}">
                        <xen:textboxunit name="event_message" value="" label="{xen:phrase xportal_event_message}">
                            <xen:explain>{xen:phrase xportal_event_message_explain}</xen:explain>
                            </xen:textboxunit>
                        <xen:controlunit label="{xen:phrase xportal_event_date}:">
                            <xen:select name="event_month" value="" inputclass="autoSize">
                                <xen:option value=""></xen:option>
                                <xen:option value="1">{xen:phrase month_1}</xen:option>
                                <xen:option value="2">{xen:phrase month_2}</xen:option>
                                <xen:option value="3">{xen:phrase month_3}</xen:option>
                                <xen:option value="4">{xen:phrase month_4}</xen:option>
                                <xen:option value="5">{xen:phrase month_5}</xen:option>
                                <xen:option value="6">{xen:phrase month_6}</xen:option>
                                <xen:option value="7">{xen:phrase month_7}</xen:option>
                                <xen:option value="8">{xen:phrase month_8}</xen:option>
                                <xen:option value="9">{xen:phrase month_9}</xen:option>
                                <xen:option value="10">{xen:phrase month_10}</xen:option>
                                <xen:option value="11">{xen:phrase month_11}</xen:option>
                                <xen:option value="12">{xen:phrase month_12}</xen:option>
                            </xen:select>
                            <xen:textbox name="event_day" value="" size="2" inputclass="autoSize" placeholder="{xen:phrase day}" />
                            <xen:textbox name="event_year" value="" size="4" inputclass="autoSize" placeholder="{xen:phrase year}" /> at 
                            <xen:textbox name="event_hour" value="" size="2" inputclass="autoSize" placeholder="{xen:phrase xportal_hour}" />
                            <xen:textbox name="event_minute" value="" size="2" inputclass="autoSize" placeholder="{xen:phrase xportal_minute}" />
                        </xen:controlunit>
                        <xen:textboxunit name="event_username" value="" label="{xen:phrase xportal_event_username}:">
                            <xen:explain>{xen:phrase xportal_event_username_explain}</xen:explain>
                        </xen:textboxunit>
            <xen:submitunit save="Save Event">
                
            </xen:submitunit>
            </xen:form>
        </div>
    <xen:include template="xportal_footer" />
    </div>
    
    <xen:require css="filter_list.css" />
    <xen:require js="js/xenforo/filter_list.js" />
    I know the input for username should grab the name of the person logged in but I have not quite figured out how to get that atm, I'll worry about that after my insert issue is resolved.
    Thanks for any and all help
     
  2. Mythotical

    Mythotical Well-Known Member

    20 views and no reply? :( Makes me very sad. Anyone able to help with this?
     
  3. ragtek

    ragtek Guest

    Same answer as always: start debugging:p

    Have you checked what Zend_Date toString returns???
    Error says that it's no integerer (as it it requested by the dw) so check Zend_Date Help and check how you can get the needed value^^
     
  4. Mythotical

    Mythotical Well-Known Member

    Thanks Ragtek. I'll check on that.
     
  5. Mythotical

    Mythotical Well-Known Member

    I figured out how to mktime() work but now to make 'new Zend_Date()' to work.
     

Share This Page