Textpattern Forum

You are not logged in. Register | Login | Help

#21 2009-03-03 20:40:11

johnstephens
Plugin Author
From: Harrisonburg, VA
Registered: 2008-06-01
Posts: 819
Website

Re: mem_simple_form

Upgrading to the latest versions of mem_form and mem_simple_form resolved all the problems I was experiencing earlier. Thank you!

Q: How can I get comments to be on by default for articles submitted through simple_form? Comments are allowed by default in my admin prefs. Is there a field in the textpattern table I can target for this?

A: Annotate=1

I added Annotate="1" like so: <txp:mem_simple_form table="textpattern" id_field="ID" id_insert="0" Annotate="1"> No errors. The article posts perfectly, but commenting remains closed.

What did I do wrong? What is the correct path? I’m thankful for your help!

Offline

#22 2009-03-09 19:24:06

johnstephens
Plugin Author
From: Harrisonburg, VA
Registered: 2008-06-01
Posts: 819
Website

Re: mem_simple_form

I’ve probably posted enough questions here to give Mr. Manfre brain cancer. So I’ll post a solution.

The correct way to enable comments on articles submitted to the textpattern table by mem_simple_form is this:

<txp:mem_form_secret name="int_Annotate" value="1" />

Offline

#23 2009-04-15 23:03:51

johnstephens
Plugin Author
From: Harrisonburg, VA
Registered: 2008-06-01
Posts: 819
Website

Re: mem_simple_form

I’m trying to create a two-step form using the success-form attribute:

  1. New category: Create a new category.
  2. Step-2: Add a new article to the same category, with the category-name preselected using a mem_form_secret field.
  3. Step-3: Success.

I’m almost there:

  1. I’ve succeeded in getting mem_simple_form to create a new category— even though I have no idea how to generate Textpattern-like category names from the titles, or how to rebuild the category tree to put stuff in the right order. Right now I’m using mem_simple_form’s randuid attribute to generate information in the name, lft, and rgt fields. I’ve verified that this form posts to the database, and the new category is recognized and operational in Textpattern.
  2. The “new category” form includes a success form attribute: success_form="step-2". This form includes another mem_simple_form to add an article to the new category. I’m using mem_form_secret in tandem with mem_simple_ps to inlcude the previous form’s input as a category. I tested it in a hidden field and I can verify that the information form the previous form is successfully transfered to the appropriate field using mem_simple_ps.
  3. The “step-2” form includes a success form attribute: success_form="step-3". This would be the form that says “You’re finished— article posted!” —but that’s where the idea fails. When “step-2” is submitted, the I never get to see my beautiful “step-3” success form; it just back to the “new category” form above. It also fails to post the article. But it doesn’t throw up any errors.

Any ideas how I could fix this? Am I straining beyond the capability of this plugin? If so, is there some other method I could use to get this working?

Thanks!

Offline

#24 2009-04-16 02:19:49

Manfre
Plugin Author
From: North Carolina
Registered: 2004-05-22
Posts: 588
Website

Re: mem_simple_form

Do all of the steps use the same url? If so, that might explain why the first step is being loaded instead of your third step.

Offline

#25 2009-04-16 02:46:39

johnstephens
Plugin Author
From: Harrisonburg, VA
Registered: 2008-06-01
Posts: 819
Website

Re: mem_simple_form

Manfre wrote:

Do all of the steps use the same url?

Yes— Step one is at example.dev/section/

When I click submit, the success-form with Step-2 loads, appending a string to the url like so:

example.dev/my-section/#mem24251a6b5ac2e0880d55a5affabcd39a

When I click submit on Step-2, a new string appears, but no success-form:

example.dev/my-section/#memcc4d59f633db8d9ca9df8cb1f54a5522

If so, that might explain why the first step is being loaded instead of your third step.

Is there a way to make the success-form load at a different url? If so, that would probably solve the problem.

Thank you again!

Offline

#26 2009-04-16 13:47:32

Manfre
Plugin Author
From: North Carolina
Registered: 2004-05-22
Posts: 588
Website

Re: mem_simple_form

Is there a way to make the success-form load at a different url? If so, that would probably solve the problem.

No, i’m just trying to get a handle of how you are using the forms. You should have each form set a hidden field that identifies which form should be rendered. Each form should be guarded by a conditional tag that checks for the appropriate hidden field to prevent the other 2 from loading.

Offline

#27 2009-04-19 03:44:48

johnstephens
Plugin Author
From: Harrisonburg, VA
Registered: 2008-06-01
Posts: 819
Website

Re: mem_simple_form

Manfre wrote:

You should have each form set a hidden field that identifies which form should be rendered. Each form should be guarded by a conditional tag that checks for the appropriate hidden field to prevent the other 2 from loading.

That sounds interesting, but I’m not sure what conditional to use or where.

I’m just trying to get a handle of how you are using the forms.

Here are my forms:

Step 1

<txp:mem_simple_form table="txp_category" id_field="id" id_insert="0" success_form="step-2">
<txp:mem_form_secret name="string_type" value="article" />
<txp:mem_form_secret name="string_parent" value="root" />
<fieldset id="add-cat-info">
	<legend>Add a Category</legend>
	<div>
	<txp:mem_form_text name="string_title" label="Title of Category" />
	<txp:mem_form_secret name="randuid_name" />
	<txp:mem_form_secret name="randuid_lft" />
	<txp:mem_form_secret name="randuid_rgt" />
	</div>
</fieldset>
<txp:mem_form_submit label="Next" />
</txp:mem_simple_form>

Step 2

<txp:mem_simple_if_ps name="string_title">
<txp:mem_simple_form table="textpattern" id_field="ID" id_insert="0" Annotate="1" success_form="step-3">
<txp:mem_form_secret name="int_Annotate" value="1" label="Comments On" />
<txp:mem_form_secret name="string_section" value="category-info" label="Section" />
<txp:mem_form_secret name="string_category1" value='<txp:mem_simple_ps name="string_title" />' label="Category" />
<txp:mem_form_secret name="string_title" value='<txp:mem_simple_ps name="string_title" />' />
<txp:mem_form_secret name="now_posted" value="" />
<txp:mem_form_secret name="string_AuthorID" value='<txp:ign_user_info type="name" />' label="Author" />
<fieldset>
	<legend>About <txp:mem_simple_ps name="string_title" /></legend>
	<div>
		<txp:mem_form_select name="string_custom_13" label="Some Metadata" items="option 1,option 2,option 3" values="option1,option2,option3" />	
	</div>
</fieldset>
<txp:mem_form_submit />
</txp:mem_simple_form>
</txp:mem_simple_if_ps>

Step 3

<h1>Confirmation</h1>

As I said, Step 2 loads successfully upon submitting Step 1, and the simple_ps data is successfully transfered from the user input of Step 1 into Step 2. But when I submit Step 2, nothing happens in the system— I don’t get a new article, and Step 3 doesn’t appear. Instead, I see Step 1 again.

I have tried wrapping the Confirmation header in Step 3 with <txp:mem_simple_if_ps> and <txp:mem_simple_if_ps name="string_title">, but the behavior is the same.

I can see setting a txp:variable with a hidden field and checking the value before rendering the forms, but it seems like the primary issue is that no data goes into the textpattern table when submitting Step 2; since it’s not a success, the success form indicated doesn’t render. Step 2 renders correctly, but it does not send anything to the database.

Maybe I’m wrong. Will this plugin let me submit input from a form rendered as the success_form of previous input? If so, where is the flaw in my markup?

Thank you again for your magnificent support!

Last edited by johnstephens (2009-07-13 19:25:11)

Offline

#28 2009-05-04 19:25:06

johnstephens
Plugin Author
From: Harrisonburg, VA
Registered: 2008-06-01
Posts: 819
Website

Re: mem_simple_form

Any ideas on this?

Offline

#29 2009-07-16 18:13:53

johnstephens
Plugin Author
From: Harrisonburg, VA
Registered: 2008-06-01
Posts: 819
Website

Re: mem_simple_form

Okay, I’ve simplified my code significantly, and I think this may help to isolate the problem. this is my form, with comments:

<!--
Check if data from STEP 2 was posted.
-->
<txp:mem_simple_if_ps name="string_custom_13">
<!--
We have data from STEP 2.
-->
<h1>Here is your data from STEP 2: <txp:mem_simple_ps name="string_custom_13" /></h1>
<txp:else />
<!--
We have NO data from STEP 2.

Render STEP 1: Category Input form.
-->
<txp:mem_simple_form table="txp_category" id_field="id" id_insert="0" success_form="_category-confirm">
<!--
This form adds an entry to the txp_category table
as specified above.
-->

<h1>STEP 1: Category Input form</h1>
<txp:mem_form_secret name="string_type" value="article" />
<fieldset id="add-category-info">
	<legend>Add a Category</legend>
	<div>
	<txp:mem_form_text name="string_title" label="Category" />

	<txp:mem_form_secret name="randuid_name" />
	<txp:mem_form_secret name="randuid_lft" />
	<txp:mem_form_secret name="randuid_rgt" />
<!--
These fields are required to successfully post a
category. This method is passing random unique
strings into these fields.

There must be a cleaner way to generate lft and
rgt and category name, but I will post a new
thread for these questions.
-->
	<txp:mem_form_secret name="string_parent" value="root" />
	</div>
</fieldset>
<txp:mem_form_submit label="Next" />
</txp:mem_simple_form>
</txp:mem_simple_if_ps>

<!--
Check if data from STEP 1 was posted.
-->
<txp:mem_simple_if_ps name="randuid_name">
<!--
We have data from STEP 1.

Render STEP 2: Article Input form.
-->
<txp:mem_simple_form table="textpattern" id_field="ID" id_insert="0" success_form="_record-confirm">
<!--
This form adds an entry to the textpattern table
as specified above.
-->

<h1>STEP 2: Article Input form</h1>
<txp:mem_form_secret name="int_Annotate" value="1" label="Comments On" />
<txp:mem_form_secret name="string_section" value="category-info" label="Section" />

<txp:mem_form_secret name="string_category1" value='<txp:mem_simple_ps name="randuid_name" />' label="Category" />
<!--
We want to categorize this article under the
category created in STEP 1.

Here, we pass the category name into a hidden
category field.
-->

<txp:mem_form_secret name="string_title" value='<txp:mem_simple_ps name="string_title" />' />
<!--
The article will have the same title as the
category.
-->

<txp:mem_form_secret name="now_posted" value="" />
<txp:mem_form_secret name="string_AuthorID" value='<txp:ign_user_info type="name" />' label="Author" />
<!--
Enter the author name from the current ign_user.
-->
<fieldset>
	<legend>
		About <txp:mem_simple_ps name="string_title" />
	</legend>
	<div>
		<txp:mem_form_select name="string_custom_13" label="Select something" items="option 1, option 2, option 3" values="option 1, option 2, option 3" />
	</div>
</fieldset>
<txp:mem_form_submit />
</txp:mem_simple_form>
</txp:mem_simple_if_ps>

I’m no longer loading STEP 2 in the success_form of STEP 1.

Last edited by johnstephens (2009-07-16 20:27:31)

Offline

#30 2009-07-16 20:27:42

johnstephens
Plugin Author
From: Harrisonburg, VA
Registered: 2008-06-01
Posts: 819
Website

Re: mem_simple_form

Here are the results.

  1. When I load the page in my browser, I immediately see the input form for STEP 1, since it doesn’t see any data from STEP 2.
  2. After I complete STEP 1 and click submit, STEP 1’s success_form renders, AND I see the input form for STEP 2. The form seems to correctly load all the information it needs that was submitted in STEP 1.
  3. When the second form submits, I see *Here is your data from STEP 2: option x*— which shows that textpattern recognizes data was submitted from STEP 2.
  4. However, STEP 2’s success_form does NOT render, and NO RECORD is added to the textpattern table. There is also no error message from mem_simple_form.

Can anyone see where I’ve made a mistake in my markup, logic, or anywhere else?

I’d love to hear any guidance, support, suggestions, or feedback. Please let me know what you think.

Offline

Board footer

Powered by FluxBB