TOPIC:

add date/time to textfield at or after form submission 10 months 2 weeks ago #251576

  • samy's Avatar
  • samy
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 29
  • Thanks: 4
Hi...

How about using Content Builder only (without Breezing Form), how to automatically add date/time while submit the form?

Thanks before.

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

add date/time to textfield at or after form submission 10 months 2 weeks ago #251580

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 7381
  • Karma: 3
  • Thanks: 529
Hi,

if you are using only CB then go to Editable Prepare and put this:
$items["NAMEOFYOURDATEELEMENT"]["value"]=date("Y-m-d H:i");
Please replace NAMEOFYOURDATEELEMENT with name of your date element.
With this date element is automatically populated with submitted date.

Regards,
Tihana

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

add date/time to textfield at or after form submission 10 months 2 weeks ago #251705

  • samy's Avatar
  • samy
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 29
  • Thanks: 4
$items["NAMEOFYOURDATEELEMENT"]["value"]=date("Y-m-d H:i");

Thanks Tihana.
But this script will saved the datetime when the form was loaded first time, not when the form submitted.
For example:
I open the form (to create new entry) at 2020-12-10 22:00
I submit the form at 2020-12-10 22:04

How to save the datetime when submit the form : 2020-12-10 22:04 ?

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

Last edit: Post by samy.

add date/time to textfield at or after form submission 10 months 2 weeks ago #251707

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 7381
  • Karma: 3
  • Thanks: 529
Hi,

put this in item wrap code of date element:
<?php  $currentdate = date("Y-m-d h:i"); $value = $currentdate;?>

When you put new record this date element is empty, but when you submit this in list view you will see date of submission. (we can make this date element readonly->in Views->View->go to date element->Editable->click on [text]->Options->scroll down and check Readonly)

Regards,
Tihana

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

Last edit: Post by tihana.krivic.

add date/time to textfield at or after form submission 10 months 2 weeks ago #251710

  • samy's Avatar
  • samy
  • Offline
  • Junior Breezer
  • Junior Breezer
  • Posts: 29
  • Thanks: 4

tihana.krivic wrote: Hi,

put this in item wrap code of date element:

<?php  $currentdate = date("Y-m-d h:i"); $value = $currentdate;?>

When you put new record this date element is empty, but when you submit this in list view you will see date of submission. (we can make this date element readonly->in Views->View->go to date element->Editable->click on [text]->Options->scroll down and check Readonly)

Regards,
Tihana


Thanks Tihana.

When I put this code into item wrap code, it change all the "input date" [this is my element name] in the list view to the current date.
It effects to all the records that have been saved in the list view [column "input date"], all become the same current date.

Btw, I just need to show "input date" in detail view, not list view :)

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

Last edit: Post by samy.

add date/time to textfield at or after form submission 10 months 2 weeks ago #251712

  • tihana.krivic's Avatar
  • tihana.krivic
  • Offline
  • Moderator
  • Moderator
  • Posts: 7381
  • Karma: 3
  • Thanks: 529
Hi,

ok. I tested it now, and got it. Sorry for waiting.

Go to CB->View->Views->in date field->Editable->click on [text]->go to Scripts->Init (JS)->and put this in Init code:
var date1=new Date();
contentbuilder.onSubmit(
   function(){
       contentbuilder._('nameofdatefield').value = date1.getFullYear() + "-" + (date1.getMonth()+1) + "-" + date1.getDate() + " " + date1.getHours() + ":" + date1.getMinutes();
       return true;
   }
);
Please replace nameofdatefield with name of field for date (not title).

Let me know the result

Regards,
Tihana

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

Moderators: ForumSupport
Time to create page: 0.044 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!