Date function in textbox in Chronoforms V5

Arkomat 11 Oct, 2014
Hi All,

I can't get the following to work and can't find the answer in the forum.
What I want is this. In the form I'd like to have a hidden textbox with the current year in it's value.

Of course I can keep changing the year every time the form gets online but I'd like to have it dynamic with a php Date() function.
Now the little script <?php echo Date('Y') ?> worked in V4 when put into the value field of the hidden textbox but somehow it doesn't seem to work in V5.

I also tried to use the extra parameters box with value=<?php echo Date('Y') ?> but then the first value is empty and I can't get the Year value in the database when saving.

Can anyone please help?

Grtz
Arkomat
Arkomat 11 Oct, 2014
Unfortuntely that's not what I mean. I just want the value "2014" for this year (and autmatically "2015" next year) in the value field of the hidden text box.

Grtz
Arkomat
Arkomat 11 Oct, 2014
Answer
I solved the problem with this thread "http://www.chronoengine.com/forums/posts/t97393/p335513/set-textfield-value-from-php.html#p335513".

In "Setup" I added a "Custum code" event before the "HTML (Render Form)" event in the "OnLoad" Section.
In the "Custum code" event I added the following code:
<?php $form->data['speeljaar'] = Date('Y');?>
(where "speeljaar" is the "Field ID" for the hidden field)

This resulted in:
<input name="speeljaar" value="2014" id="speeljaar" type="hidden" class="form-control A" />
when looking at the page source code.
GreyHead 13 Oct, 2014
Hi Arkomat,

That will work well.

Note: If you don't need to show the Year in the form HTML you can just add the same custom code in the On Submit event and leave out the hidden input.

Bob
This topic is locked and no more replies can be posted.