Hi Piotr,

One approach that you could try is having the types that you expect to
validate against as a separate field consisting of your sequence types.
When your form is submitted, you would read that field first and
dynamically generate the schema you wish to validate the rest of your
request against. Alternatively, you could have the validation type and
element data as sub objects to your request and then validate each type
based on the validation type field. That was probably a bit confusing, so
are some examples of what your form posts would look like as JSON:

types: [ 'iPhone', 'android', 'windowsPhone'],
fields: [
  {
   iosVersion: '...'
   serialNumber: '...'
  },
  {
    androidVersion: '...',
    serialNumber: '...'
  },
  {
    windowsVersion: '...',
    productId: '...'
  }
]

- or -

fields: [
  {
    type: 'iPhone',
    data: {
      iosVersion: '...'
      serialNumber: '...'
  },
  {
    type: 'android',
    data: {
      androidVersion: '...',
      serialNumber: '...'
  },
  {
    type: 'windowsPhone',
    data: {
      windowsVersion: '...',
      productId: '...'
  }
]

I don't have too much experience with Deform, but I have used Colander
quite extensively. Unfortunately, this will require some programming on
your part to dynamically build the schema to validate against whenever your
form is submitted.

Hope this helps!

-Vincent

On Tue, Aug 25, 2015 at 5:46 AM, Piotr Dobrogost <
[email protected]> wrote:

> Hi!
>
> I'm seeking advice on how to go about making it possible to dynamically
> add fields of different types to deform sequence widget. One idea is to
> have each element of a sequence be a mapping with fields of all possible
> types and hide all but the one desired. In other words there would be kind
> of variant type (each element of sequence would be of this type) when only
> one out of all possible fields would be visible and others would be hidden
> and discarded when submitted. What problems do you see with this approach?
> Is there a better way? I haven't found any previous discussion on this
> subject on this list – did I miss any?
>
> Thank you in advance for sharing your thoughts on this.
>
> Regards,
> Piotr Dobrogost
>
> --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/pylons-discuss.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Vincent Catalano
Software Engineer and Web Developer,
(520).603.8944

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to