KK wrote:Not a problem. Just set the default_time of the 'datetime' region to the publish_date of the page being edited and that would be it.My problem is that I should be able to edit the saved publish date also from the front-end, ideally using datepicker or if this isn't possible, other way. What do you think about this, is it possible?
Sample code -
- Code: Select all
<cms:set my_form_mode='edit' />
<cms:input
name='my_datetime'
type='datetime'
default_time="<cms:if my_form_mode='edit' && k_page_date!='0000-00-00 00:00:00'><cms:show k_page_date /><cms:else />@current</cms:if>"
required='1'
/>
In the code above we are setting the default_time to the page's publish date only if the page is being 'edited' (as opposed to being 'created') and is not in an 'unpublished' state.
In you happen to be using Couch v2.0, the documentation at viewtopic.php?f=5&t=10241 has a full-fledged example where we use a custom-field to mimic the system publish field. I suggest you take a look at how it works.
Hope it helps.
Thank you KK for the quick reply. I'm using this code:
- Code: Select all
<cms:form
masterpage='members/folders.php'
mode='edit'
page_id=my_page_id
enctype="multipart/form-data"
method='post'
anchor='0'
>
<cms:if k_success >
<cms:db_persist_form
k_publish_date=frm_my_datetime
/>
</cms:if>
Date*<br />
<cms:input name='my_datetime' type='datetime' default_time="<cms:show k_page_date />" required='1' /><br />
<button type="submit"><i class="fa fa-floppy-o" aria-hidden="true"></i>Save</button>
</cms:form>
Thank you.