My first time posting here :)

I have a system where many emplyees can post a form with DB and i wanted a unique ID for each page and for this me and Trendoman had to make a AUTO generate function. Maybe someone else have the use for this :)

Here it goes in 4 steps:

1. Make a editable like this and place it between <template> and </template>

Code: Select all
    <cms:editable 
        name="id"
        type="text"
[b]    search_type='integer'
        validator='non_zero_integer'[/b]
        required='1' />


2. Set last and next ID and place the following before the FORM tag <cms:form......

Code: Select all
<cms:set last_id = "<cms:pages masterpage=k_template_name limit='1' orderby='id' order='desc' show_future_entries='1' ><cms:show id /></cms:pages>" scope='global' />
<cms:set next_id = "<cms:add last_id '1' />" scope='global' />


3. Add some changes to db_persist_form

Code: Select all
<cms:db_persist_form 
_invalidate_cache='1'
_mode='create'
_masterpage=k_template_name
_auto_title="1"

id=frm_id                                                                                                               

/>


4. And finaly make the <cms:input field.....

Code: Select all
<cms:input name='id' type="text" placeholder="<cms:show next_id />" value="<cms:show next_id />" class="form-control" />


And there you go :) Now your form will always make a unique ID and the ID also follows if you deleted pages direct in admin section.

A sweet and amazing function, and thanks to Trendoman for helping on this