[Zope3-Users] Re: Standalone forms for z3c.form groups

Fernando Correa Neto fcdoth at gmail.com
Sun Feb 10 16:43:05 EST 2008


Mmm.....reading the email I think it is a bit confuse.

What I am really trying to do is:

class ISomeContent(Interface):
    some_field = zope.schema.List(title='Some Field',

value_type=zope.schema.Object(title=u'Some Field',

             schema=IOtherContent)
                                                             )

class SomeForm(formui.EditForm)
    fields = field.Fields(ISomeContent)

So yes, I am trying to get a new ObjectWidget to render a automatic
form of the schema attribute of the ObjectField, IOtherContent in this
case, in the modal window. That would be kinda a meta-form because all
what the modal window would do is to put all the fields back in the
main form so it could be processed by the main form class.

Sounds crazy? Any ideas?

Kind regards,
Fernando
On Feb 10, 2008 2:03 PM, Fernando Correa Neto <fcdoth at gmail.com> wrote:
> Hello there!
>
> I've been playing with z3c.form for quite a while and have drunk a lot
> of its Kool-aid already and I decided that I would need a reference
> widget/gadget. Widget in a sense of simple html representation and
> gadget in a sense of really complex and nasty stuff under the
> hood....think of Vista gadgets ;).
> Anyways, I've started developing that and one of the requirements is
> that if there is no reference in the source reference, then it would
> allow for creating a new reference by simply clicking in the '
> Register new %(field_name)s' that opens a ajax modal window with the
> group-subform(?) loaded inside of it. IOW, one would not need to
> navigate away from the original form to create a new reference if
> there is no reference in the source. All the exception handling will
> be treated to address permission issues while creating new source
> reference objects.
>
> My main question now is: Am I allowed to provide a html form for a
> group form so I can load its fields inside the ajax modal window? I
> know I can access the group form like this:
>
> (Pdb) self
> <AjaxReferenceGadget 'form.widgets.place'>
> (Pdb) self.__parent__.form
> <processmanager.browser.forms.PlaceSupplierGroup object at 0x3692450>
> (Pdb) self.__parent__.form.update()
> (Pdb) self.__parent__.form.render()
> *** ContentProviderLookupError: pagelet
>
> But rendering it would be a different story as you see.
> So, what I'm thinking to have a "modal" form that shows the fields of
> a group form like this:
>
> <div class="row">
>           <label for="form-widgets-id">ID</label>
>           <input type="text" id="form-widgets-id"
>                  name="form.widgets.id"
>                  class="text-widget required textline-field"
>                  value="" />
>         </div>
>         <div class="row">
>           <label for="form-widgets-name">Name</label>
>           <input type="text" id="form-widgets-name" name="form.widgets.name"
>                  class="text-widget required textline-field"
>                  value="" />
>         </div>
>        <div class="action">
>           <input type="submit" id="form-buttons-add" name="form.buttons.add"
>                  class="submit-widget button-field" value="Register"
> onclick="Javascritp:
> injectTheContentOfThisModalFormIntoTheOriginalForm()" />
>         </div>
> </div>
>
> 1) Main form loads;
> 2) No reference was found in the vocabulary of the reference field and
> a button is displayed labelled with "Register new ...";
> 3) By clicking on the button, the modal window opens up and try to
> load (via ajax) the group form fields in it;
> At this point the widget would be responsible for setting up the
> markup of the group form by doing python registrations on-the-fly ( i
> guess)...meaning, providing enough context so the form above can be
> loaded/rendered properly.
>
> The reason I need this widget and not a subform as pointed in z3c.form
> doctests, is that I am going to have loads of reference fields in this
> app and will need something that can be reused in a quick and
> consistent way. Creating subforms for all of this object fields would
> not be good for this case.
>
> Any ideas on how to render a group form?
> Also, can anybody validate if what I am trying to do is way too much
> and not the correct way of doing it?
>
>
> Regards,
> Fernando
>


More information about the Zope3-users mailing list