It would be nice to have a pre-saved data summary page (Like a review page in ecommerce system). Similiar to draft functionality. Not showing fields but the submitted data (via e.g. view).
The user could "go back" and change his value(s).

Comments

ericc3’s picture

I second that, this will be a great feature to have. I currently use a multi-page form, so having a summary page will help the user.

tedbow’s picture

Issue tags: +entityform-2.x feature

Agreed this would a good feature. Marking it as a possible feature for 2.x which I am going to start on soon.

See #1896712: [Meta] Features and Changes for Entityform 2.x

adrianmak’s picture

this could be a good feature to display a summary of what form data user is selected before confirm to submit.

adrianmak’s picture

is there any work around solution before 2.x come out ?
I really need this feature

tedbow’s picture

I think there would be custom programming. Beside that it doesn't seem so.

bjcooper’s picture

I also need the feature pretty urgently, so I'm willing to (forced to, rather) begin working on a patch for it in the mean time.

I imagine I'll try to replicate what the Node module does it for its node 'Preview' prior to node creation. Anyone got any thoughts or pointers as to how it should be done?

tedbow’s picture

I am thinking that it should be a checkbox option on the Entityform Type like "Show review before submit". So not all forms would have to have it.

It should not happen on Draft.

Fields should be validated before the Preview(they aren't validated on draft).

There should probably be a new "preview" View Mode which would determine which fields would be shown on the Preview screen.

The entityform should not actually be saved to the database until after the Preview screen is accepted.

There should be a "back" button to change the submission.

It will need to work with multi-page forms that are created with the Field Group module.

tedbow’s picture

I imagine I'll try to replicate what the Node module does it for its node 'Preview' prior to node creation.

1 major difference I see in how the preview should act for Entityforms as oppose to nodes is Node preview shows on the same page as the add/edit form for nodes. I think it separate "review" screen for entityforms.

tedbow’s picture

@bjcooper if want to contact me directly about this work, feel free. There is contact form/info on your Drupal.org account profile so I can't contact you.

kasalla’s picture

What about a drupal common confirmation page?
D6 -> http://drupal.org/project/confirm
D7 -> http://drupal.org/node/470834
D7 API -> http://api.drupal.org/api/drupal/modules%21system%21system.module/functi...

That would...
...be easy to implement (Sorry guys, I have no time to give you a patch)
...keep drupal best practise
...make the process reusable
...give us "view mode". $form_state holds the entity object, so "view mode" can be used. (the rendered entity as $question param in confirm_form();)
...give us a chance to perhaps define a new hook to allow other modules (and rules etc) to interact on that process

tedbow’s picture

@kasalla I don't think that will work b/c it is really not meant to be used by another form, in our case the entityform_edit_form.

This is more to confirm an action you about to take like deleting an entity.

From: http://drupal.org/node/470834

Sometimes it is useful to display a confirmation message before processing a form, especially when doing something irreversible, like deleting content.

While this a useful explanation for the front end user it is misleading to as to what is happening in the form system in Drupal. When you are on the node edit screen and you click the "delete" button what happens is

  1. The add/edit form is submitted.
  2. Drupal then sends you a separate form created by the conform_form function. This form is passed the nid of the node so it know which form to delete.
  3. This form is completely separate

I think this will more be like a multi-step form. You can see an example in the Examples module, the form_example submodule multistep example.

kasalla’s picture

Hey, Thanks for the reply.
I had the same thoughts on this. Perhaps doing a multi-step-form is more suitable for that target.

However, I don´t really think that a confirmation page is the wrong way in those situations. The confirm_form just confirms a form, irrespectiv of its purpose. It´s the last step before an action takes place. Is it just about security? I don´t think so. If it´s not meant to be used in things like node-saving (and leaving preview out), there is a failure in concepts.
If we talk about a preview (like in node handling) we have to stay inside our form and a confirmation makes no sense. Right. But if not, a confirmation is fully sufficiant.

I will give it a try and see what happens :-)
In the Meanwhile mark this a "possible quick work-around"

tedbow’s picture

@kasalla 1 problem I think that you are going to run into is the that confirm_form function use a $path variable to determine where the user is redirected to if they "cancel" the form.

$path: The page to go to if the user cancels the action. This can be either:

A string containing a Drupal path.
An associative array with a 'path' key. Additional array values are passed as the $options parameter to l().

So the problem when using with entityforms is that when the user clicks cancel(we might label it "go back") then they will lose the state of the current submission. With a multi-step form you can retain the $form_state.

kasalla’s picture

Good point.
The only way would be to store the $form_state in $_SESSION variable, keyed by a individual identifier (e.g. the form id) which is added to the cancel-link.

tedbow’s picture

The only way would be to store the $form_state in $_SESSION variable, keyed by a individual identifier (e.g. the form id) which is added to the cancel-link.

This would add complexity that isn't needed just to use confirm_form for something it really isn't meant to do. Adding info into $_SESSION would be a last resort.

I have been thinking about this and doing it via a multi-step form would not be that difficult. Just haven't had time.

bjcooper’s picture

These are great points; thanks @tedbow and @kaslla. I've just had another project come up, so I won't be working on this quite yet. We'll see who gets time first.

tedbow’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
StatusFileSize
new5.1 KB

Here is quick first try. It will probably need work but it does work for me. It is against 2.x

Please review.

tedbow’s picture

Status: Active » Needs review

Changing to needs review

tedbow’s picture

I have committed this to 7.x-2.x. Still could use some review

kasalla’s picture

Wie built a rather complex form, so I hope you can use this info anyway.

Versions: D7.21, 7.x-2.x-dev
Other modules used inside the form:
- Entityreference (with views filters)
- Field Collection (and Entityreference inside a collection)
- Date
- Textfield
- Selectlist
- Dependent Fields

We´ve updated from Version 7.x-1.1 (just to see what may happen).
Following Errors/Warnings occure when preview page comes up.

Notice: Undefined index: view modes in field_view_mode_settings() (Zeile 627 von /var/www/vhosts/oncru.de/httpdocs/modules/field/field.module).
Warning: Invalid argument supplied for foreach() in field_view_mode_settings() (Zeile 627 von /var/www/vhosts/oncru.de/httpdocs/modules/field/field.module).

tedbow’s picture

Thanks for report. I haven't seen this

    $entity_info = entity_get_info($entity_type);
    foreach ($entity_info['view modes'] as $view_mode => $view_mode_info) {
      if (!isset($settings[$view_mode]['custom_settings']) && $view_mode_info['custom settings']) {
        $settings[$view_mode]['custom_settings'] = TRUE;
      }
    }

This is were the error is coming from but our implemantion of hook_entity_info provides 'view modes'. So maybe it is coming from another entity providing module that used on the form?

If you want to figure it out you could either set debug or add these lines in(temporarly of course)

    $entity_info = entity_get_info($entity_type);
     if (!isset($entity_info['view modes'])) {
        drupal_set_message("entity type $entity_type has no view modes");
    }
    foreach ($entity_info['view modes'] as $view_mode => $view_mode_info) {
      if (!isset($settings[$view_mode]['custom_settings']) && $view_mode_info['custom settings']) {
        $settings[$view_mode]['custom_settings'] = TRUE;
      }
    }
kasalla’s picture

Yap, did it.
$entity_type is empty.
dsm($entity_type); returns nothing.

EDIT: $bundle is empty too.

tedbow’s picture

Strange, to figure out if this related to viewing this screen you could try a couple things:

  1. Make a very simple form and see if it has this problem. Then try to add other fields to it.
  2. Try to use the 'review' view mode in way besides this screen,like make a View that list submissions using the 'review' mode. Does the problem everytime this view mode is displayed.
tedbow’s picture

Status: Needs review » Fixed

Changing fix to clean up 2.x issues

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sylwester’s picture

<?php
$form['actions']['submit']['#submit'] = array('custom_submit','entityform_edit_form_submit');
?>

That works very well. The problem is when I enable form preview before submission. custom_submit function runs before preview is generated and not after it was confirmed.