Forums

CF4 - Detailed Records Page with Edit/Delete & Check Boxes

codeslayer 25 Sep, 2011
Hi,

Reference to guide DB Multi Record Loader in Tutorials section.
Instead of displaying records back into their form within form elements. How do we show selected records in the next page called "Details"?

Regards

Hassan
GreyHead 25 Sep, 2011
Hi Hassan,

I think that I would put the DB Multi Record Loader action in the On Load action of the 'Details' form.

Bob
codeslayer 28 Sep, 2011
Hi Bob,

I am not sure how to show results from multi record loader into next page called "details". It should be like as the results we get in email (using curly braces to show the recordset fields)
Could you please guide me step by step. I know it must be very simple. but I am lost. ๐Ÿ˜Ÿ

Regards
Hassan
GreyHead 28 Sep, 2011
Hi Hassan,

There's a code sample in page 6 of the tutorial.

Bob
codeslayer 28 Sep, 2011
Hi Bob,

Thankyou for your reply.
The code is there and it is working good. The refered code sample shows all the records in the table + an edit link button which upon click takes the user to user_details form page for editing, if required.
Following are the screen shot.
Basic DB Multi Record Loader to show all the records as table list.
[attachment=1]Screenshot_1.png[/attachment]

If edit button clicked:
[attachment=0]Screenshot_2.png[/attachment]

So far so good. The selected row data is being displayed in the next form for editing.

Now, what I want is acheive is more than covered in the tutorials section. May be its simple php, but I am not good enough to do it my self. Please see the screenshots below.

[attachment=2]Screenshot_4.png[/attachment]

Number 1, The edit is working just like in the CF4 DB Multi Record Loader, tutorial.

Number 2, When "Buy" is clicked. How can I show the selected record (including more fields not showing in this list) in new a window/page?. Just likewe do in email template ({field_1}, {field_2}, ...}) ex:

Alright, I figured it out. As usual it was simple, thanks to the powerful features of Chronoforms CF4. Just in case if anybody else is interested. I replaced the input form elements with "Custom Code Element". in the spanner, put the following code:

Story Name: {fn_Story_name}
Grenre: {fn_SoryGenre}
Author: {fn_StoryAuthor}
Date: {fn_Story_Date}
Language: {fn_StoryLanuage}
Price: {fn_StoryPrice}
Upload File: {fn_upload}


Number 3, How can I delete selected row?

Number 4, How can I make select all row checkbox, select single or multiple rows and add buttons Buy, Edit and Delete under the list. Just like usual record tables.

Please help me.

Regards
Hassan
GreyHead 29 Sep, 2011
Hi Hassan,

Number 2. Create a form just like number one but in the Form HTML use the . . . .Oh, I see you;ve solved that one.

Numer 3. Set a URL for the Delete link that includes something like task=delete and use a form that just has Custom Code to check for this link and if it is there delete the record (or mark it as unpublished).

Number 4. I don't know, there is basic code in Joomla! to do this but it's a long time since I used it.

Bob
codeslayer 29 Sep, 2011
Hi Bob,

Number 3, I have no clue where to put task=delete in url. It would be great if you could explain with some example. I have searched the forum but could not find any delete record example for CF4.

Number 4, Its just like in CF4 Forms manager window. How to have such functionality in CF4 froms?

Best regards,
Hassan
GreyHead 30 Sep, 2011
Hi Hassan,

3) I think that the Delete URL would be similar to the Edit URL. It might be simplest to pass it to a different form:
<a href='index.php&option-com_chronoforms&chrononame=del_record&cf_id={cf_id}' >Delete</a>


4) See my previous answer. If you work it out please let us know.

Bob
codeslayer 30 Sep, 2011
Ok Delete URL is ok. But what to include in the del_record form.
As per my understanding there will be DB Record loader on On Load function. In the spanner I have to put the uniquire record id in the BD field to filter the selected row. In the Request Param I would put "token" as value will be used to load the target db record.

But what will be query to include in WHERE Statement to delete that particular record?
GreyHead 01 Oct, 2011
Hi Hassan,

I'd do the delete in a Form, not in ChronoConnectivity. All you need in the Form HTML is something like this:
<?php
$task = JRequest::getString('task', '', 'get');
if ( $task = 'del' ) {
  $cf_id = = JRequest::getInt('cf_id', '', 'get');
  if ( $cf_id 0 {
    $db =& JFactory::getDBO();
    $query = "
      DELETE
        FROM `#__some_table`
        WHERE `cf_id` = '{$cf_id}' ;
    ";
    $db->setQuery($query);
    $db->query();
  }
}
$mainframe =& JFactory::getApplication();
$mainframe->redirect('some url');
?>

I'd probably add more validation and would flag the record as 'unpublished' instead of deleting it.

Bob
Max_admin 05 Oct, 2011
Hi Hassan,

Some ideas:

#3- you can do this in a new form OR in a new event (I prefer this), just add the same url for the current form but at the end:
&event=delete
and add a new event to your form, call it "delete" and use a basic SQL DELETE statement, just like Bob has mentioned, you will be passing the key value and so you just need to run the statement through PHP, don't forget to add some security to this event, for example, an Authenticator to check for specific groups + some "Custom server side validation" to check if the current user is owner or something like that, it depends on your logic.

#4- ticking some checkboxes and clicking an "Edit" button would edit the FIRST ticked checkbox (you should find all the ticked boxes values in the form data array), and clicking the delete button would simply loop the ticked values and delete each one, you already have an event to delete one record with the key passed in the URL so you may try this code in your loop, it would execute the delete event in your loop:


//assuming your checkboxes are named "item[]", and that you are passing the key value to the "delete" event in url parameter named "cf_id"
<?php
foreach($form->data['item'] as $item){
$form->data['cf_id'] = $item; // this will set the "cf_id" parameter to the current item value
$form->process('delete'); //this will run the delete event
}
?>


I hope this is helpful๐Ÿ™‚

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
codeslayer 05 Oct, 2011
Thank for your replies Bob and Max. ๐Ÿ™‚

This delete and checkbox functionality is going a little above my head. Since it is my first time ever to have checkbox/grid tables layout, I'll try to make way into it by collecting pieces by pieces secrhing on this board. Its really too hard to find for answered similiar questions using search here. The results are all mixed up with different versions. I use both "board search" and "GreyHead search" link on his website. But I thing you should reconsider changing Board structure.

lightbulb By the end of my project I'll write a descriptive tutorial "ChronoForms Step by Step - The CodeSlayers Way". ๐Ÿ™‚
Max_admin 06 Oct, 2011
No problems, and let me know if you couldn't make it and I can create an example for you or even create a new "list editor" action๐Ÿ˜‰

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
codeslayer 09 Oct, 2011
Hi Max,

I am too embarrassesd to admit I couldn't do it. ๐Ÿ˜ถ
I would request you if you could provide me any example. The action plugin idea is even better. lightbulb

I will be really grateful to you.

Regards
Hassan
codeslayer 28 Oct, 2011
Hi Max / Bob,

Any update with the new list editor action plugin or any example ?

Regards

Hassan
crea2k 11 Dec, 2011
Hi, I am trying to add a delete link to my page and have followed the above but cant seem to get it to work, when clicking delete all I get is a blank page, and when I go back to the list the item hasnt been deleted.

I created a form to do the deleting called deletelead , I added the load html action, and in the code of the form added .
<?php
$task = JRequest::getString('task', '', 'get');
if ( $task = 'del' ) {
  $cf_id = = JRequest::getInt('cf_id', '', 'get');
  if ( $cf_id 0 {
    $db =& JFactory::getDBO();
    $query = "
      DELETE
        FROM `hqfjt_chronoforms_data_addupdatelead`
        WHERE `cf_id` = '{$cf_id}' ;
    ";
    $db->setQuery($query);
    $db->query();
  }
}
$mainframe =& JFactory::getApplication();
$mainframe->redirect('index.php');
?>


On my view page I have the following code, but clicking on the delete just give the above problem, I also have a problem with the edit button too, when clicked it goes to the form I made to submit data but doesn't import the fields from the database and just presents a blank form.

<table class="sortable">
<tr class="table-header">
<td>Name</td>
<td>Company</td>
<td>Postcode</td>
<td>Gas Oil</td>
<td>Derv</td>
<td>Kero</td>
<td>Edit</td>
<td>Delete</td>
</tr>
<?php
foreach($form->data['leaddetails'] as $detail):
?>
<tr>
<td><?php echo $detail['leadname']; ?></td>
<td><?php echo $detail['businessname']; ?></td>
<td><?php echo $detail['postcode']; ?></td>
<td><?php echo $detail['gasoiluser']; ?></td>
<td><?php echo $detail['dervuser']; ?></td>
<td><?php echo $detail['kerouser']; ?></td>
<td><a href="index.php?option=com_chronoforms&chronoform=addupdatelead&token=<?php echo $detail['cf_uid']; ?>">Edit</a></td>
<td><a href='index.php?&option-com_chronoforms&chrononame=deletelead&<?php echo $detail['cf_uid']; ?>' >Delete</a></td>
</tr>
<?php
endforeach;
?>
</table>


Sorry if im a bit rubbish, its my first time doing anything more advanced than contact forms etc with chrono so its hard work.
This topic is locked and no more replies can be posted.