Hi all,
I have re-posted this from the Chronoconnectivity form because I realised that I had posted in the wrong place. Sorry...
I'm a relative beginner and while I could easily create a form to add records to a database table, I did not find a tutorial on how to create an edit/delete capability for the table. So after some research and trial and error, I made quite a bit of progress as follows:
1. Made a copy of my data entry form and added a field with the cf_id in it.
2. Created a new form with one field, to enter the cf_id for a record I wished to edit (Select_form).
3. Added some form code into my Select_form (copied and modified from another post) to create a dynamic redirect URL. The code is in the onSubmit "after" box:
I then created a Profile page for the edit form, selecting the table and the field name (cf_id) and using the request parameter cf_id which matches the parameter in the url.
The select form works, and the redirect url populates the edit form with the correct record. Good so far...
I can change data in the form, but when I submit the edited data the form works, the debug record looks fine, but the record is not updated in the DB. Is there some code I need to put in the edit form on Submit to update the record?
Also I can't see how to make a Delete capability.
Hope someone can help me over this hurdle - I know it is inexperience only and apologise in advance if this is a silly question.
Cheers
Tim
I have re-posted this from the Chronoconnectivity form because I realised that I had posted in the wrong place. Sorry...
I'm a relative beginner and while I could easily create a form to add records to a database table, I did not find a tutorial on how to create an edit/delete capability for the table. So after some research and trial and error, I made quite a bit of progress as follows:
1. Made a copy of my data entry form and added a field with the cf_id in it.
2. Created a new form with one field, to enter the cf_id for a record I wished to edit (Select_form).
3. Added some form code into my Select_form (copied and modified from another post) to create a dynamic redirect URL. The code is in the onSubmit "after" box:
<?php
// get the parameters
$record = JRequest::getString('cf_id', '', 'post');
$record = urlencode($record);
// create the redirect url
$url = 'index.php?option=com_chronocontact&chronoformname=2012_Entry_Edit&cf_id='.$record;
// set the ChronoForms ReDirect URL to the new value
$MyForm->formrow->redirecturl = $url;
?>I then created a Profile page for the edit form, selecting the table and the field name (cf_id) and using the request parameter cf_id which matches the parameter in the url.
The select form works, and the redirect url populates the edit form with the correct record. Good so far...
I can change data in the form, but when I submit the edited data the form works, the debug record looks fine, but the record is not updated in the DB. Is there some code I need to put in the edit form on Submit to update the record?
Also I can't see how to make a Delete capability.
Hope someone can help me over this hurdle - I know it is inexperience only and apologise in advance if this is a silly question.
Cheers
Tim
Hi Tim,
Sorry I've been putting off replying to this (and the earlier post) because it looked complicated and I've been overwhelmed with posts. I'm afraid to say that the simple ones tend to get priority.
This does indeed look complicated.
The 'usual' way of editing a table data is to list the table using ChronoConnectivity and to include in the Body box either (a) an {edit_record} tag or(b) a direct chronoform link like the one you have in your OnSubmit After box
To make sure that the data is saved you need (a) a DB Connection enabled in the form and (b) to make sure that the value of cf_id is set usually by including it in a hidden input in the form.
Bob
Sorry I've been putting off replying to this (and the earlier post) because it looked complicated and I've been overwhelmed with posts. I'm afraid to say that the simple ones tend to get priority.
This does indeed look complicated.
The 'usual' way of editing a table data is to list the table using ChronoConnectivity and to include in the Body box either (a) an {edit_record} tag or(b) a direct chronoform link like the one you have in your OnSubmit After box
<a href='index.php?option=com_chronocontact&chronoformname=2012_Entry_Edit&cf_id={cf_id}'>Edit Record</a>Both methods take you back to a ChonoForm to edit the record. I prefer route (b) as it gives me more control over the process; route (a) is simpler though as ChronoForms automates part of the process.To make sure that the data is saved you need (a) a DB Connection enabled in the form and (b) to make sure that the value of cf_id is set usually by including it in a hidden input in the form.
Bob
Thanks Bob,
Now I see where to put the code I can create the Edit Record easily by either method.
So my complicated method can be discarded - I guess it was a learning process and it did actually get me somewhere...
So now I can hit the edit Record on either front-end or admin, and the edit form comes up populated. I can change data, but when I submit the data the DB record is not changed.
As far as I can see the only two differences between the data entry form and the edit form are
1. A Text Box displaying the field cf_id. I used a Text Box for simplicity, once it works I can play around with the Hidden Field.
2. There is no email sent from the edit form.
The DB Connection seems to be identical, data storage is enabled, form method is Post, emails not enabled, CSS/JS (whatever that is..) set to Yes.
Must be something I have missed.
Cheers
Tim
Now I see where to put the code I can create the Edit Record easily by either method.
So my complicated method can be discarded - I guess it was a learning process and it did actually get me somewhere...
So now I can hit the edit Record on either front-end or admin, and the edit form comes up populated. I can change data, but when I submit the data the DB record is not changed.
As far as I can see the only two differences between the data entry form and the edit form are
1. A Text Box displaying the field cf_id. I used a Text Box for simplicity, once it works I can play around with the Hidden Field.
2. There is no email sent from the edit form.
The DB Connection seems to be identical, data storage is enabled, form method is Post, emails not enabled, CSS/JS (whatever that is..) set to Yes.
Must be something I have missed.
Cheers
Tim
OK...
I found the solution. I enabled emails on the General Tab of the Edit form (even though I am not sending an email) and it worked🙂
So all is well, one less problem for you to worry about.
Many thanks for all your good work.
Tim
I found the solution. I enabled emails on the General Tab of the Edit form (even though I am not sending an email) and it worked🙂
So all is well, one less problem for you to worry about.
Many thanks for all your good work.
Tim
Hi, Tim
I am very much glad hearing your issue.
cause I have also same problem.
I inserted the data in database using chronoform but could not edit and delete that data.
so, Please can you give me the right way in details. how is it possible!!
anybody else are very welcome to suggest me.
Thanks
infoashwi
I am very much glad hearing your issue.
cause I have also same problem.
I inserted the data in database using chronoform but could not edit and delete that data.
so, Please can you give me the right way in details. how is it possible!!
anybody else are very welcome to suggest me.
Thanks
infoashwi
Oh dear,
This worked for a couple of days but then stopped editing when I added a couple of additional fields to the form and table.
I have set up my CC list as suggested above using the href example in the earlier post and cf_id is the primary key. In my edit form I have cf_id in a text box so I can see what is happening.
If I go to the CC list and select "Edit Record" the edit form appears but is not populated.
If I go to "Show Data" view and select a record and edit, then the edit form appears and is populated except for the cf_id text box which is blank. In this form I can change data but Submit does not change the record. I tried entering the cf_id value manually but this did not work either.
Sorry again.. obviously I am not doing this right but I cannot see where I have gone wrong.
In case it is helpful the code for the first couple of form fields is:
Cheers
Tim
This worked for a couple of days but then stopped editing when I added a couple of additional fields to the form and table.
I have set up my CC list as suggested above using the href example in the earlier post and cf_id is the primary key. In my edit form I have cf_id in a text box so I can see what is happening.
If I go to the CC list and select "Edit Record" the edit form appears but is not populated.
If I go to "Show Data" view and select a record and edit, then the edit form appears and is populated except for the cf_id text box which is blank. In this form I can change data but Submit does not change the record. I tried entering the cf_id value manually but this did not work either.
Sorry again.. obviously I am not doing this right but I cannot see where I have gone wrong.
In case it is helpful the code for the first couple of form fields is:
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 150px;">Primary Key</label>
<input class="cf_inputbox" maxlength="150" size="30" title="" id="text_36" name="cf_id" type="text" />
</div>
<div class="cfclear"> </div>
</div>
<div class="form_item">
<div class="form_element cf_textbox">
<label class="cf_label" style="width: 150px;">Entry Number</label>
<input class="cf_inputbox" maxlength="150" size="30" title="" id="text_37" name="cf_user_id" type="text" />
</div>
<div class="cfclear"> </div>
</div> Cheers
Tim
Hi Tim,
It looks as though you made some major changes to the form.
What are those two inputs that you posted supposed to do?
Why do you need to edit either the cf_id or the cf_user_id values? My guess is that the cf_id probably needs to be in a hidden input and the cf_user_id shouldn't be there at all.
Bob
It looks as though you made some major changes to the form.
What are those two inputs that you posted supposed to do?
Why do you need to edit either the cf_id or the cf_user_id values? My guess is that the cf_id probably needs to be in a hidden input and the cf_user_id shouldn't be there at all.
Bob
OK...
I made a hidden field, with value = cf_id, and removed the cf_user_id field.
everything else the same.
And I get the same result. from Show Data I get the record populating the form, but no db update. If I click Edit Record on the CC list I get a blank form.
I can see (I think) how it should be working, but obviously I have missed something important.
Cheers
Tim
I made a hidden field, with value = cf_id, and removed the cf_user_id field.
everything else the same.
And I get the same result. from Show Data I get the record populating the form, but no db update. If I click Edit Record on the CC list I get a blank form.
I can see (I think) how it should be working, but obviously I have missed something important.
Cheers
Tim
Hi Tim,
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
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
Hi Tim,
This is now partly working - I think that the missing parts are because of mismatches between the form input names and column names in the table.
I've enabled the Profile Page plug-in on the 2012_Entry_Edit form. This is configured to look for the cf_id parmeter in the calling URL, get the matching data and pre-load it in the form for editing.
I also changed the hidden input to give it name='cf_id' and value='' this will track the record and make sure that it is updated.
I've also set the form ReDirect URL to the ChronoConenctivity url so that you go back to the listing after saving the edit.
Bob
PS I also installe EasySQL to see the Db records. It doesn't seem to find the table list correctly but if you type in the query it's fine.
This is now partly working - I think that the missing parts are because of mismatches between the form input names and column names in the table.
I've enabled the Profile Page plug-in on the 2012_Entry_Edit form. This is configured to look for the cf_id parmeter in the calling URL, get the matching data and pre-load it in the form for editing.
I also changed the hidden input to give it name='cf_id' and value='' this will track the record and make sure that it is updated.
I've also set the form ReDirect URL to the ChronoConenctivity url so that you go back to the listing after saving the edit.
Bob
PS I also installe EasySQL to see the Db records. It doesn't seem to find the table list correctly but if you type in the query it's fine.
Thanks Bob,
2 things I missed were how to set up the hidden field (name=cf_id, value={cf_id}) and the need to set the Profile page.
The mismatch in the field names to columns names is OK as it happens, as there are a couple of unused columns in the table that I have not removed.
One other thing I have noticed is that somehow in the edit wizard I have got two radio button fields generating the same name (radio4). It's just a mild annoyance in that if I use the wizard I have to edit the code afterwards. Is there a way to access and change the name that a particular radio button generates from the wizard?
Heaps of beer will be delivered shortly. You do like Aussie beer, I hope🙂
Cheers and thanks again
Tim
2 things I missed were how to set up the hidden field (name=cf_id, value={cf_id}) and the need to set the Profile page.
The mismatch in the field names to columns names is OK as it happens, as there are a couple of unused columns in the table that I have not removed.
One other thing I have noticed is that somehow in the edit wizard I have got two radio button fields generating the same name (radio4). It's just a mild annoyance in that if I use the wizard I have to edit the code afterwards. Is there a way to access and change the name that a particular radio button generates from the wizard?
Heaps of beer will be delivered shortly. You do like Aussie beer, I hope🙂
Cheers and thanks again
Tim
I am trying to get this to work
I have created a new form and added a hidden cf_id field as below,
<input value='' id="hidden_12" name="cf_id" type="hidden" />
I have created a profile page with the request parameter being cf_id (also connected to the table and selected the cf_id field from the drop down list). My plugin is enabled, emails are set to yes on the general page of the new form.
My links come from another component but copied from the browser it is http://mywebsite/index.php?option=com_chronocontact&chronoformname=EditAddlease&cf_id=11
It is not working, the form is not being populated at all.
Did I miss something?
I have created a new form and added a hidden cf_id field as below,
<input value='' id="hidden_12" name="cf_id" type="hidden" />
I have created a profile page with the request parameter being cf_id (also connected to the table and selected the cf_id field from the drop down list). My plugin is enabled, emails are set to yes on the general page of the new form.
My links come from another component but copied from the browser it is http://mywebsite/index.php?option=com_chronocontact&chronoformname=EditAddlease&cf_id=11
It is not working, the form is not being populated at all.
Did I miss something?
Hi luisa,
It sounds OK. Does the table you are looking the results up in have a cf_id column? (It will probably do so if it was created in ChronoForms but not otherwise).
Bob
It sounds OK. Does the table you are looking the results up in have a cf_id column? (It will probably do so if it was created in ChronoForms but not otherwise).
Bob
Yes it does
On the form I copied - I did not edit any of the fields - do I have to replace the fields with {column_name} to pull the data. Or will it just self populate based on the code already on the form
On the form I copied - I did not edit any of the fields - do I have to replace the fields with {column_name} to pull the data. Or will it just self populate based on the code already on the form
Hi luisa,
Bob
do I have to replace the fields with {column_name} to pull the data
Yes, I believe that you do. Add a couple of test entries to check.Bob
any other suggestions? think i have followed everything in this thread... it doesn't seem to be picking up the cf_id whatever i do. the plugin is enabled.
This topic is locked and no more replies can be posted.
