Unique number with strtotime
Hi, I would like to create a unique number for each resource I create via a Formit call.
I think the best way is to use a snippet that retrieves current time (with seconds, which is a unique number), that will run as a prehook when the form is loading. Also make a placeholder to use this number in several places inside form.
I am not sure if the code below will give results.
I think the best way is to use a snippet that retrieves current time (with seconds, which is a unique number), that will run as a prehook when the form is loading. Also make a placeholder to use this number in several places inside form.
I am not sure if the code below will give results.
<?php
$unique = date('ymdHis',strtotime('NOW'));
$modx->setPlaceholder('time', $unique);
return ''; Комментарии: 11
Авторизуйтесь или зарегистрируйтесь, чтобы оставлять комментарии.
2. Don`t you want to return true from your hook?
rtfm.modx.com/extras/revo/formit/formit.hooks#FormIt.Hooks-UsingpreHooks
[[+serialnumber]] at &ajaxuploadUid=`image_[[+serialnumber]]` returns blank. I guess that snippet inside Formit call doesn't work. In ground zero again…
But you can insert any value into submitted data inside hook — see docs.
So unique snippet runs, and placeholder should work. No?
Anyway, you could assign any value to submitted data in hook:
I will run it as a prehook. And how I retrieve this value (serialnumber) in &ajaxuploadUid?
P.S. Sorry for my naive questions.
Why do you need this random sting in form, by the way?
What I want, is to give the user the ability to edit own resources. Almost working. Only one problem left.
Unique snippet