TOPIC:

add date/time to textfield at or after form submission 4 years 6 months ago #200712

  • Topic Author
  • mhbadmin
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 8
  • Thanks: 0
I'm baffeled how I am unable to perform such a simple task.

I simply want to use the ff_setValue('element', $value); to set the date/time at the submission time of form.

I think this is already being done behind the scenes as I used to see it in one of my view in ContentBuilder.

$this->execPieceByName('ff_InitLib');
date_default_timezone_set('America/Chicago');
$currenttime = date('m/d/Y -- h:i:s a', time());
ff_SetValue('checkintime', $currenttime);

[checkintime] is a textfield at the bottom of the form which I'm displaying in a view using ContentBuilder

What am I doing wrong? I'm not sure what I'm supposed to do with $this ->.

Thank you for your help.

Please Log in or Create an account to join the conversation.

add date/time to textfield at or after form submission 4 years 6 months ago #200731

  • tomeperica's Avatar
  • tomeperica
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 6478
  • Karma: 170
  • Thanks: 674
Hey there,

can you pls set that code in Form Pieces -> Before form

$this->execPieceByName('ff_InitLib'); it must be used so you can actually use methods/funcitons like ff_SetValue so its crucial to have that.

Regards,
Tome
Regards,
Tome
==========================================
Need to renew Pro Support?
Buy Here!
==========================================
Satisfied?
Consider a membership!
==========================================
Like us on Facebook
==========================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!

Please Log in or Create an account to join the conversation.

add date/time to textfield at or after form submission 4 years 6 months ago #200733

  • Topic Author
  • mhbadmin
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 8
  • Thanks: 0
Thanks for responding Tomeperica! Yes, my code contains the execPieceByName otherwise you get "unkown function" error.

Right above the date_default_time... line I placed it.

Please Log in or Create an account to join the conversation.

add date/time to textfield at or after form submission 4 years 6 months ago #200735

  • tomeperica's Avatar
  • tomeperica
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 6478
  • Karma: 170
  • Thanks: 674
Ok I meant to place this whole code in Form Pieces -> Before form -> Custom
$this->execPieceByName('ff_InitLib');
date_default_timezone_set('America/Chicago');
$currenttime = date('m/d/Y -- h:i:s a', time());
ff_SetValue('checkintime', $currenttime);

I tested that with simple form with one textfield and I can see the date and time.

Regards,
Tome
Regards,
Tome
==========================================
Need to renew Pro Support?
Buy Here!
==========================================
Satisfied?
Consider a membership!
==========================================
Like us on Facebook
==========================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
The following user(s) said Thank You: mhbadmin

Please Log in or Create an account to join the conversation.

Last edit: Post by tomeperica.

add date/time to textfield at or after form submission 4 years 6 months ago #200753

  • Topic Author
  • mhbadmin
  • Offline
  • Fresh Breezer
  • Fresh Breezer
  • Posts: 8
  • Thanks: 0
Yes, it does work. The problem is Form Pieces -> Before enters the time when the form is rendered not when it's submitted. So the form could be sitting there for 20 minutes and then it's submitted. The "CheckInTime" will be 20 minutes too early, inaccurate.

If it works with Pieces -> Before, why doesn't it work with Submit Pieces --> Begin Submit?
((==> Before Submit: PHP that will be executed before the form is going to be submitted. You can use this for example catching values and prevent storing a submission.))

I'm treating Begin Submit like onSubmit which is what I need. When the form is submitted put Date/Time in element 'checkintime'.
I have a Backend view (using ContentBuilder) that shows all of the fields that the form submitted.

Please Log in or Create an account to join the conversation.

Last edit: Post by mhbadmin. Reason: unfinished sentence

add date/time to textfield at or after form submission 4 years 5 months ago #200789

  • tomeperica's Avatar
  • tomeperica
  • Offline
  • User is blocked
  • User is blocked
  • Posts: 6478
  • Karma: 170
  • Thanks: 674
Ok here how things are working, to get the current realtime value we need to use JavaScript not PHP, so I research a bit and found a cool solution with Moment.js library. pls follow the steps below.

1. Create a folder called js in media/breezingforms/js and put in it 3 files I attached you below:
- moment.js
- moment-timezone.js
- moment-timezone-with-date.js

2. Put this code into your Form Pieces -> Before Form -> Custom:
$this->execPieceByName('ff_InitLib');
echo '<script src="'.JURI::root().'media/breezingforms/js/moment.js"></script>';
echo '<script src="'.JURI::root().'media/breezingforms/js/moment-timezone.js"></script>';
echo '<script src="'.JURI::root().'media/breezingforms/js/moment-timezone-with-data.js"></script>';

3. I guess your element is called checkintime like you said in first post. Now Go to Scripts -> Initialization Script -> Create new framework and put setInterval function in it (look how my example looks)
function ff_YOURFORMNAME_init()
{
setInterval(timeTrack, 500);
          
} // ff_YOURFORMNAME_init

function timeTrack() {
var timeValue = moment().tz('America/Chicago').format('hh:mm:ss a');
var dateValue = moment().format('L');
           ff_getElementByName('YourElementName').value =dateValue + ' -- ' + timeValue;
}

So you only need to change the YourElementName with checkintime

4. Go to your frontEnd check the form and you will see date and time in real time ;)

Test the form now and let me know the result.

Regads,
Tome
Regards,
Tome
==========================================
Need to renew Pro Support?
Buy Here!
==========================================
Satisfied?
Consider a membership!
==========================================
Like us on Facebook
==========================================
Support Crosstec and get ALL EXTENSIONS and professional support for just $5
Here!
Attachments:
The following user(s) said Thank You: mhbadmin

Please Log in or Create an account to join the conversation.

Moderators: ForumSupport
Time to create page: 0.051 seconds

BreezingForms Pro 1.4.7 for WordPress Released!

Available in the membership section.

September Discount!

Massive discounts on all subscriptions!

Get Your Subscription Here

Quick Links

Downloads

BreezingForms

ContentBuilder

BreezingCommerce

Templates

Documentation

BreezingForms

ContentBuilder

BreezingCommerce

Apprendre BreezingForms (French Community)

Apprendre et maîtriser BreezingForms par des tutoriels et exemples, le tout en français

breezingforms.eddy-vh.com

Questions et réponses sur les forums de l'AFUJ

AFUJ

Special Offer

Summer Sale! All subscriptions at a special price!

Includes prio support, all of our current and future Joomla!® extensions and Joomla!® templates for the duration of your membership.

Get it from here

3rd Party Discount - 25% Off

We help you to keep your costs under control. If you are a new member and purchased a form building tool from a different form vendor, then you'll get a 25% discount on our subscription plans.

How to receive the discount:

Send us a quick email to sales@crosstec.org with a proof of purchase (for example a paypal receipt), await payment instructions and enjoy your membership!