Sam, PHP is not required - we can use Couch variables to set the page id.
Both the following methods should work (assuming we are using it in page_view of the page to be edited) -
Hope this helps.
Both the following methods should work (assuming we are using it in page_view of the page to be edited) -
<cms:form masterpage='index.php' mode='edit' page_id=k_page_id method='post'>
<cms:form masterpage='index.php' mode='edit' page_id="<cms:show k_page_id />" method='post'>
Hope this helps.