Simple as that. I can't find straightforward and easy example how to use it, and the place I expected it is here.
Could somebody add this? Like, in confirmation about deleting entries or something?
http://api.drupal.org/api/drupal/modules!system!system.module/function/c...

Seems code from http://api.drupal.org/api/drupal/modules!aggregator!aggregator.admin.inc/7 might be good, but it's not written in a self-explanatory way and I have some irritating doubts and little problems with it.

Comments

mile23’s picture

Title: confirm_form » Add confirm_form() example to FormAPI example
Category: feature » task
Issue tags: +Novice

Yah, that's a bit of an omission.

I'd say it belongs in the FormAPI module even though it's not officially part of the FormAPI.

Tagging as Novice.

wolffereast’s picture

Status: Active » Needs review
StatusFileSize
new7.15 KB

I added an 11th example to the form API example module.

This is my first patch so any and all suggestions/revisions/you-did-this-completely-wrong-and-heres-how-to-do-it-differentlys are welcome!

mile23’s picture

Status: Needs review » Needs work

Thanks, wolffereast.

Looks good for a first-timer. :-)

Just a couple things:

  1. +++ b/form_example/form_example_tutorial.inc
    @@ -765,3 +766,102 @@ function form_example_tutorial_10_submit($form, &$form_state) {
    +//////////////// Tutorial Example 11 //////////////////////
    

    We generally don't have comments like that. Thanks for being consistent with the other wrong ones, though. :-)

  2. +++ b/form_example/form_example_tutorial.inc
    @@ -765,3 +766,102 @@ function form_example_tutorial_10_submit($form, &$form_state) {
    + * Adds a submit handler/function to our form to redirect
    + * the user to a confirmation page
    + */
    +function form_example_tutorial_11_submit($form, &$form_state) {
    

    Missing a few @ingroups.

joachim’s picture

  1. +++ b/form_example/form_example_tutorial.inc
    @@ -4,7 +4,7 @@
    - * It goes through 10 form examples of increasing complexity to demonstrate
    + * It goes through 11 form examples of increasing complexity to demonstrate
    

    I'd say just reword that to not specify a number, save having to update this in future! :D

  2. +++ b/form_example/form_example_tutorial.inc
    @@ -25,11 +25,12 @@
    -  return t('This is a set of 10 form tutorials tied to the <a href="http://drupal.org/node/262422">Drupal handbook</a>.');
    +  return t('This is a set of 11 form tutorials tied to the <a href="http://drupal.org/node/262422">Drupal handbook</a>.');
    

    Same here!

wolffereast’s picture

I've applied most of the changes, I'm just stuck on the ingroup issue.
Mile23 - can you point me in the direction of some ingroup standards? I was following what I found on the comment standards page (https://drupal.org/node/1354#functions) under the 'Form-generating functions' header. Other than the @ingroup form_example what do I need to add?

mile23’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests
StatusFileSize
new12.66 KB

Docs for @ingroup and @defgroup are here: https://drupal.org/node/1354#defgroup

Most important is this convention: You can @defgroup a group in the .module file, but then you declare @ingroup on functions in other files.

In our case, we want all of the functions to show up on api.drupal.org, so we @ingroup them all. form_example_tutorial_11_submit() doesn't have an @ingroup.

Actually, there are quite a few missing @ingroups in other functions as well.

And.. How could I have overlooked it? No tests! :-)

Attached is #2 with @ingroups added in form_example_tutorial.inc.

Regression tests checking that the menu routing works, and that the confirmation page shows the right name would be great.

mile23’s picture

Status: Needs review » Needs work

OK, needs tests to keep it all green, please.

Mołot’s picture

Status: Needs work » Needs review

I see tests in #6 all green now.

mile23’s picture

Sorry. I mean it needs regression tests for the future. Regression tests checking that the menu routing works, and that the confirmation page shows the right name would be great.

wolffereast’s picture

Thanks for the link, exactly what I was looking for! I'll take a look at the regression testing when I get a chance, that's new to me as well though so it may take a bit...

wolffereast’s picture

StatusFileSize
new13.8 KB

Once more unto the breach, dear friends, once more;
I took the patch from 6, changed the comments according to 3 and 4, and added regression testing.

in regards to the regression testing I am not sure if the tests I put in are what you are looking for, I couldn't find a way to test the actual form field on the confirmation page so I added a print message and tested against that. Hopefully that works.

Status: Needs review » Needs work

The last submitted patch, examples-add-confirm-form-1973508-11.patch, failed testing.

wolffereast’s picture

Alright, I fixed the initial issue on the test but have run into another problem. I am uploading another patch and marking it to avoid testing so you can see what I am talking about. I am having an issue with my last assertText statement (the 'This is my name' assertion). it is returning false even though I see the appropriate statement outputting when I run through the form by hand.

Any direction would be appreciated!

wolffereast’s picture

Yeesh, forgot to port one my changes to the test document. This doesnt fix the issue, but it does remove one of the things that could have been an issue. Sorry about the extra posts

mile23’s picture

Issue summary: View changes
Status: Needs work » Needs review
StatusFileSize
new14.68 KB
new7.99 KB

Fixed the tests, fixed some formatting, added some inline comments...

Also disabled the textfield on the confirmation form. It's good to demo placing form elements within confirm_form(), but the user shouldn't be able to edit the name there.

  • Mile23 committed 5fbb2ee on 7.x-1.x authored by wolffereast
    Issue #1973508 by wolffereast, Mile23 | Mołot: Add confirm_form()...
mile23’s picture

Status: Needs review » Fixed

Aaaaand.... Committed. :-)

Thanks, wolffereast!

Status: Fixed » Closed (fixed)

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