Forums

pre-populate fields

iacoposk8 05 Mar, 2012
Hello everyone!
I created a form for editing data previously entered on db (again via form)
I would make sure that the fields of the form (editing) are filled with the values ​​on db.
I created a url like: index.php?name_form form=&field1=&field2=1 and the form fields with the same names.
The form is completely filled with the right values​​.
But if I modify them and hit submit nothing happens on the db!
If the url does not pass any value, value is empty and properly update the fields ...
why?
GreyHead 05 Mar, 2012
Hi iacoposk8,

Which version of ChronoForms are you using? You can find the version from Site Admin | Extensions | Install/Uninstall | Components in Joomla! 1.5 or Site Admin | Extensions | Extension Manager | Manage in Joomla! 1.6/1.7/2.5.

Bob
GreyHead 05 Mar, 2012
Hi iacoposk8 ,

If you use a DB Record Loader in the ON Load event (drag it before the Show HTML action) then ChronoForms will pre-populate any inputs with matching names. You need to include the prinary key column from the table in a hidden input.

You then need a DB Save action in the form On Submit event to save the edited data.

Bob
iacoposk8 05 Mar, 2012
If I have:
text field named "singer"
text field named "number of cd"
etc.

and create a url like:
index.php?option=com_chronoforms&chronoform=name_form&cf_id=12
fields are empty.
if it creates a url like:
index.php?option=com_chronoforms&chronoform=name_form&cf_id=12&singer=boh&number_of_cd=5
I see the fields filled in correctly but if I press "submit" in the database is the text contained in "value" and not what I have inserted
GreyHead 05 Mar, 2012
Hi iacoposk8 ,

Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

Bob
iacoposk8 06 Mar, 2012
thank you so much for the availability
You're very kind🙂
GreyHead 06 Mar, 2012
Hi iacoposk8,

Thanks for the form backup. I've looked at it but I have no idea at all what the form is trying to do.

If you want to edit a record then you probably want the DB Record Loader action (not the DB Multi Loader) to load a single record. The action in your form has no configuration settings so I can't work out what should be passed in the URL.

The custom code that you have tries to echo $form->data['details'] but fails because that entry doesn't exist in the $form->data array.

Bob
iacoposk8 06 Mar, 2012
in event > custom code i wrote:

<?php
foreach($form->data['details'] as $det)
{
echo $det['cf_id']." - ".$det['test']." - <a href='index.php?option=com_chronoforms&chronoform=test&cf_id=".$det['cf_id']."&test=".$det['test']."'>edit</a><br />";
}
?>

Because there is the array? Record the configuration DB Multi Record Loader, in Model id I wrote: "details"
I need to display multiple records in the db.
The backup did show me the records and put it in properly.
If I click on edit it shows me the completed form, but if I write a new text in the field test will not be updated in the database.
iacoposk8 08 Mar, 2012
if you want I can give you new information, to help me🙂
This topic is locked and no more replies can be posted.