You can change the datefield format to Y-m-d in the Date Format box on the Form General tab. Or you can add PHP in the OnSubmit Before box to convert from one format to the other.
Bob
I changed the datefield format to Y/m/d, it still doesn't get saved into the database.
Could you help me with the code to convert it to the right format?
If I open a record where the date is not yet filled (0000-00-00) I can't open the datebox.
Is it normal, I can't manually type a date and the field is grey?
Yes, tha's normal if you use a datepicker field.If you use different date formats for the datepicker and the database table (and most of the time you do) then you need code to switch between them.
If you have Y-m-d as the datepicker input format then all dates should work OK apart from the empty ones. These will show as '0000-00-00' in the database but need to be '' for the date-picker.
You can sort this with a PHP snippet in the Form HTML.
<?php
if ( !$mainframe->isSite() ) { return; }
$date = ??? // this line depends on your form
if ( $date == '0000-00-00' ) {
$date = '';
}
?>
Bob
The name of the field in the database is Datum. I changed the code as follows:
<?php
if ( !$mainframe->isSite() ) { return; }
$date = Datum // this line depends on your form
if ( $date == '0000-00-00' ) {
$date = '';
}
?>
I put the code in the middle of the form code, is this the right place?
It's the right place for the code but this line won't do anything:
$date = Datum
You need to have good PHP in there - presumably the code to get the value from the database. It depends on how the rest of your form is working.Bob
First of all: i love Chronoforms! I recently made a new form and I decided to use the 'save data to database'-option as a reassurance. Good idea, since I messed up the mail to-fields, so all my filled in-forms were gone.
But...I don't quite understand this database-thing. I chose a jos_contacts-table I think and thought that Chronoforms would just dump the form input there. But now I can't find any one of those 'lost' forms, because, of course there is nu relation to the inputfields on my form and the fields of the database.
So I've got two questions
1. How, if at all, can I retrieve the form data from the jos_contacts-table?
2. Since I am clearly clueless about the way Chronoforms and MySql can be combined, where could I find more info on, creating or editing tables to backup my form data savely?
Thank you for any suggestions,
egs
Please check the Database Tutorial from the Tutorials link above.
Bob
Hi pokemon,
It's the right place for the code but this line won't do anything:
$date = Datum
You need to hav good PHP in there - presumably the code to get the value from the database. It depends on how the rest of your form is working.Bob
It works with this code. Thanks Greyhead for all your help.
<?php
if ( !$mainframe->isSite() ) { return; }
$date = JRequest::getVar('datefieldname'); // this line depends on your form
if ( $date == '0000-00-00' ) {
$date = '';
}
?>
For the Fresh Boarders like me:
I found some explaination for getVar here http://docs.joomla.org/Retrieving_data_from_GET_and_POST_requests
I used VARCHAR type for my datefield.
I still have a problem, saving the data : (not only the datefield but ) all fields I added manually (not with the wizard)
Those fields are not in the autogenerated code tab.
How can I get them there?
http://www.chronoengine.com/forums.html?cont=posts&f=2&t=11793&p=23875
Re: Auto Generated Field gets lost after Update
Postby GreyHead ยป Wed Feb 18, 2009 9:31 am
Hi Tejas,
From ChronoForms v3.0 on you can't edit the Autogenerated Code (or rather if you do then ChronoForms over-writes it).
You can still execute code in a similar way in the OnSubmit After code box. If you need it to execute after the AutoGenerated code (because you need the record id for example) then change the settings in the Run Order tab so that OnSubmit After rund after the Autogenerated Code.
Bob
And I changed the Run Order tab so that OnSubmit After runs after the Autogenerated Code. This doesn't have any effect.
You need to refresh the DB Connection after any changes to database column names. In the Form Editor click the DB Connection tab and set the Connection to 'No'. Click the 'Apply icon in the toolbar to save the form, open the DB Connection tab, set the Connection back to 'Yes' and re-save the form. This will refresh the copy of the table information that ChronoForms uses.
Bob
I reconnected the table, put the connection on 'yes'.
If I trie to change (with chronoconnectivity edit) a record I saved with the first form, I don't see the data in my fields (the data was saved).
If I open the form from the backend of chronoconnectivity, I see the data.
Do you have an idea where I have to look for solving this?
It sounds like the DB Connection needs refreshing to get ChronoForms to recognise all the table fields. I'm not clear if you've done this or not.
I don't use the ChronoConnectivity 'edit record' tags so I'm not sure exactly how they work.
Bob
I copied all the code of the other form into this form but this included some php to count a sum.
And I made the form all over again trying not to forget any field. Of course I forgot 1. I set the database to no and erased all fields in the auto-generated tab, put database on yes again. And, yes the forgotten field was found.
Finally,I can get further in my development.