What you can do is this:

<validator class="equals" severity="info" provides="step1">
  <argument>stagename</argument>
  <ae:parameter name="value">stage1</ae:parameter>
</validator>
<validator class="equals" severity="info" provides="step2">
  <argument>stagename</argument>
  <ae:parameter name="value">stage2</ae:parameter>
</validator>
... etc, and then use depends="step1" and so forth.

However, there is a much better way that most people use:

<route name="products" pattern="^/products" module="Products">
  <route name=".create" pattern="^/create">
    <route pattern="^$" action="Create" />
<route name=".step1" pattern="^/step1$" action="Create" method="step1" constraint="write" /> <route name=".step2" pattern="^/step2$" action="Create" method="step2" constraint="write" />
  </route>
</route>

Products_CreateAction::executeRead() brings up the first form and POSTs to .step1, which will run Products_CreateAction::executeStep1(); on Success, you show the second form in there which submits to .step2, which will run Products_CreateAction::executeStep2(), and there, in the third form, you submit to .create (!), which will run Products_CreateAction::executeWrite().

Keep in mind that you either need to store the intermediary step values in a session or populate hidden fields.

This has several advantages:
- you can still POST to /products/create, e.g. for an API, without going through the wizard steps - all the responsibilities for actually creating the product are in executeWrite(), so you can add other means of access (the aforementioned API, or a SOAP interface etc etc) - in the validation config, you can do <validators method="step1" and so forth to group things.

Hope that helps,

David


On 30.09.2009, at 14:37, Michal Charemza wrote:

Hi,

I'm making a wizard with multiple stages, all being submitted to the
same action. The stage is in the URL like:

/somestageofwizard/
/anotherstageofwizard/

etc.

Each wizard stage has a form, and need to be validated. However, I
only want each stages' validators to run on that stage. What is the
best way of going about this?

I have tried using regex validators for "stagename": each test against
a particular stage name, and "provide" a dependency to the validators
specific to that stage. However, this always results in the
"stagename" being marked as invalid, as it can only satisfy one of the
regex validators.  I would like a way to "provide" a value that is
equal to the submitted stagename: this would allow attributes like

depends="somestageofwizard"

in the validator definitions, to ensure they only run on their stage.

Is there someway to do this? Is there maybe a better way?

Michal.

_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
users mailing list
[email protected]
http://lists.agavi.org/mailman/listinfo/users

Reply via email to