A question about Displaying Data from table that form just created

Can you use the same form to display a record of the fields just submitted by a form? Same form but populated with data after selecting a drop down element for record selection is what I have in mind.... Possible?
 
Think he means, that you have a db join dropdown with a list of possible records, selecting an entry from the dropdown would load the record into the form.

It might be possible although its not something I have ever tried, with the autofill form plugin. However, you may need to write some custom js to update the forms hidden 'rowid' field with the selected value in the dropdown, otherwise upon submit you would most likely create a new record and not update the selected record
 
Think he means, that you have a db join dropdown with a list of possible records, selecting an entry from the dropdown would load the record into the form.

It might be possible although its not something I have ever tried, with the autofill form plugin. However, you may need to write some custom js to update the forms hidden 'rowid' field with the selected value in the dropdown, otherwise upon submit you would most likely create a new record and not update the selected record

That would work... I was looking at the cascading dropdown but kept getting a 500 error...
 
From what I understood on our Skype conversation, he wants to create a new row, but based on values from a previous row. So if he's adding, not editing, rowid should already be 0, and as long as he doesn't map the PK value in the autofill JSON map, that should work.

-- hugh
 
What I am looking for is this situation...

1) User enters data on form...
2) User submits form...
3) User realizes there is an error on one of the fields submitted...
4) User wants to edit that record....

How can the record be displayed in the form view with the data that was entered when the form was first submitted allowing the user to see the error and edit it to the correct/desired value...
 
Between step 2 and 3, how would they know that they have made a mistake? You would need to re-show the stored data somehow. So you could either:

Use the form confirmation plugin, which adds a confirmation screen showing the selected data and asking them to confirm its ok before actually storing the data.

Or use a form redirect plugin to redirect them back to the form. So say your form is at this url:
index.php?option=com_fabrik&view=form&formid=1&rowid=0

your redirect url would be
index.php?option=com_fabrik&view=form&formid=1&rowid={rowid}

{rowid} is replaced with the submitted records' primary key value enabling you to re-edit the same form.
 
Thanks Rob
Well it has happened before.... hitting the submit button then the user realizes they forgot something... but ideally they would be able to pull up the record for review and see if it does need editing

Okay I like those two options... but to actually be able to pull up a record to edit after noting an error later can that be done using a dropdown element showing the records they have submitted and they could select a record to edit from that list?

If you have a redirect in the form already does that mean you have to delete that plugin and put in the confirmation plugin first then the redirect plugin?
 
Okay I like those two options... but to actually be able to pull up a record to edit after noting an error later can that be done using a dropdown element showing the records they have submitted and they could select a record to edit from that list?
Hmm no not really. You could redirect to a list view prefiltered on the users records. That would presume that the user was logged in when creating records.

If you have a redirect in the form already does that mean you have to delete that plugin and put in the confirmation plugin first then the redirect plugin?

No the order of the plugins in this case is not important - the redirect plugin always runs last.
 
The requirement requested from the user is that on situations they are required to leave before completing a form... These forms are rather lengthy... they would like to save their work up to that point and then come back and complete it some time later in the day. How could that accomplished?
 
Well, there's several approaches you can take, which rather depend on the circumstances.

The main problem with "saving" an "uncompleted" form is obviously validation. We won't save the form unless everything validates, so if you have any validations on elements they haven't filled out yet, then they can't save the form.

One way round this is to use the "save partially completed multipage forms" option, under the Form Processing section in your form settings. However, this relies on a) enabling multipage, which means picking the groups you want to put page breaks at, and configuring the group settings accordingly, and b) the user using the "Next" button, to move to the next page, as least once.

The process of moving from one "page" to the next of a multipage form is what triggers us to save the state of the form in a temporary session table, indexed by either the userid (if logged on) or IP address (and a couple of other secret ingredients) if they aren't logged on. When moving between pages, we validate ONLY those elements on the page that we just left. So the "data so far" stored in the session table is validated, but only for the pages that have been filled out (or rather, have been moved away from).

So ... which approach to take kind of depends on whether you do much validation, and whether our multipage functionality works for you.

NOTE - we have had a couple of issues in the past with the session handling when using the multipage features. I think those are resolved, but if you run in to problems, we'll need to get that fixed. It may work just fine, but I just wanted to give you a heads up that I'm not 100% sure we've resolved all of the potential gotchas with the session saving.

-- hugh
 
Ooops, didn't finish my train of thought.

If you don't do any validation, then you could take an approach that doesn't need a multipage form, and just uses our normal list functionality. You could let them submit the form, then have a link to a list that shows "their" rows (using the user element and ACL's on the list), and let them edit any of their rows in the list.

With this approach, you might want to include a checkbox at the end of the form, which basically says whether they want to "submit" or just "save" the form, then you can have another view of the list which filters on "submitted", for your staff / admins / whatever (folk who need to deal with the submitted forms), using the pre-filter options on the menu link, rather than on the list settings itself.

Actually, thinking about it, you coud actually use this approach to control whether to apply validations or not. All of our validation rules include a "condition", where you can specify a PHP fragment that returns true or false. if it returns false, we don't run that validation. So you could put the same line of PHP on each, which just returns false if the "I want to submit this form" checkbox is not set.

-- hugh
 
No validation on this form.. it is a rating form... so basically they just click on each radio button question then add a comment...
I was thinking I could use a Dropdown to show only their rows... Each user has 1 to 5 rows max. I was wondering if I could Cascading Drop down to achieve that... along with what you are recommending...

Because the forms are long in nature... I would like to present in Form View... is that possible... is list view just like a data grid?


Or could I create a list of links like we did in the calc element plugin where it finds the row IDs for user and list them with a link to edit form using:
/index.php?option=com_fabrik&task=form.view&formid=??&rowid=??
 
I'm a little bit confused as to why, for the "edit a previously submitted form", you can't just use a standard List view, filtered by user ID. That's pretty much standard Fabrik operation. You submit forms, they get stored in lists. If you want to edit a form again, you find it in the list, and hit Edit.

-- hugh
 
They are users... they do not want to do that! LOL The list view gives a grid like appearance and the labeling and the length of form make it a bit cumbersome. Unless you are are saying not to list anything but identifying elements... How would you filter for just specific users to show in list ... I see how to do so in a menu item... but can you do so in a link?

so this would not work if you used this in a link list... index.php?option=com_fabrik&task=form.view&formid=???&rowid=???
 
Unfortunalty not as you are not allowed to have <form> tags within another <form> tag.

List dont HAVE to give a grid like appearance. I guess with a custom template you could get it to render as a dropdown:

Clone the default list template.

Edit the default.php and replace it all with this code:

Code:
<?php
/**
 * @package     Joomla
 * @subpackage  Fabrik
 * @copyright   Copyright (C) 2005 Fabrik. All rights reserved.
 * @license     http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
 */

// No direct access
defined('_JEXEC') or die;

if ($this->tablePicker != '') : ?>
    <div style="text-align:right"><?php echo JText::_('COM_FABRIK_LIST') ?>: <?php echo $this->tablePicker; ?></div>
<?php
endif;
if ($this->getModel()->getParams()->get('show-title', 1)) :?>
    <h1><?php echo $this->table->label;?></h1>
<?php endif;?>

<?php echo $this->table->intro;?>
<form class="fabrikForm" action="<?php echo $this->table->action;?>" method="post" id="<?php echo $this->formid;?>" name="fabrikList">

<?php echo $this->loadTemplate('buttons');
if ($this->showFilters) :
    echo $this->loadTemplate('filter');
endif;

?>

<div class="fabrikDataContainer">
<?php foreach ($this->pluginBeforeList as $c) :
    echo $c;
endforeach;?>

<select class="fabrikList" id="list_<?php echo $this->table->renderid;?>">
<?php
foreach ($this->rows as $groupedby => $group) :
    foreach ($group as $row) :
        echo '<option value="' . $row->data->__pk_val . '">' . $row->data->element_test___user . '</option>';
    endforeach;
endforeach;?>
</select>
        <?php print_r($this->hiddenFields);?>
</form>
<?php echo $this->table->outro;?>

<script type="text/javascript">
    window.addEvent('domready', function () {
        var select = document.id('list_<?php echo $this->table->renderid;?>');
        select.addEvent('change', function (e) {
            var v = select.get('value')
            window.location.href = 'index.php?option=com_fabrik&view=form&formid=1&rowid=' + v;
        });
    });
</script>

the part that builds the select list is:

Code:
<select class="fabrikList" id="list_<?php echo $this->table->renderid;?>">
<?php
foreach ($this->rows as $groupedby => $group) :
    foreach ($group as $row) :
         echo '<option value="' . $row->data->__pk_val . '">' .  $row->data->element_test___user . '</option>';
    endforeach;
endforeach;?>
</select>

the only thing you would need to change here is the full element name (in the above code I have used 'element_test___user ') used for the select lists' options labels.

Then the code to observe changes to the select list is :

Code:
<script type="text/javascript">
    window.addEvent('domready', function () {
        var select = document.id('list_<?php echo $this->table->renderid;?>');
        select.addEvent('change', function (e) {
            var v = select.get('value')
            window.location.href = 'index.php?option=com_fabrik&view=form&formid=1&rowid=' + v;
        });
    });
</script>

It waits till the dom is ready, observes the select list's onchange event. When that is fired it gets the select lists value (the row id to load) and redirects the browser window to that record.

You will need to change the href url, replacing the 1 in 'formid=1' with your list's form id.
 
I was able to provide a link in the Group intro that pointed to a menu item in joomla. I had set the list in the menu to have a filter. This worked nicely.
I will post pictures shortly...

Rob I like the solution you provide above... will use that in another scenario for sure!

I ended up with the Hugh provided solution with a calc element that listed the records (rows) individually so the user could edit and submit but could not delete or add. This works better for this scenario. Appreciate all the minds on this one! Thank you all!
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top