No probs, dont know if you have seen this or not also:

http://www.framework.zend.com/manual/en/zend.form.advanced.html#zend.form.advanced.arrayNotation

Array notation for form elements, ive not used this approach but it sounds
like something that may be of use.

Best wishes for the upcoming nuptials! All the best.

Dan



2009/12/20 Mike A <[email protected]>

> Thanks Dan,
>
> Problems resolved this mid-afternoon (UK time). It was a combination of
> things throwing us,
> starting with only one reference (that I found) actually setting out file
> path conventions for
> custom form decorators (always in /library). Then there's not-so-subtle
> stuff as three ways to
> invoke an element and similar repetition elsewhere. Confusion!
>
> Zend Forms don't play nicely with preload (as opposed to Post) dynamic form
> element id tags
> - the default is to provide the same id value as the addElement name. This,
> of course, is
> wholly useless for markup in cases where an array is recursed in a view -
> as it always will be
> for things like products and lists. A browser page cannot contain more than
> one id tag of the
> same name/value.
>
> I have now written a series of custom decorators for form input elements.
> To circumvent the
> above case I combine the id tag value with a unique identifier
> (id="myid_1", id="myid_2"...). I
> could not find a logical way to do this with addElement and setting 'id' =
> value. Quite happy
> with the approach now taken because it provides a lot of flexibility.
>
> Having overcome the problem I wonder how many good developers run away from
> Zend
> because of a generally poor approach to communication. The above problem
> had a simple
> solution which could, and should, have taken a short while to resolve.
> Resolution was slow
> only because of the lack of properly explained complete examples (for
> technical stuff it
> always helps to explain as one would to children and old folk - like me).
> Otherwise, Zend is a
> wonderful framework.
>
> Or maybe my brain has stalled because of the thought of getting married
> this Christmas Eve!
>
> Good luck with your form pursuits Dan!
>
> Best of the Season to all and theirs...
>
> Mike
>
> On 20 Dec 2009 at 17:31, Daniel Latter wrote:
>
> >
> > Hi,
> >
> > Ill throw my small change in, people may be packing up for hols as well.
> >
> > "$form->addElementPrefixPath('My_Form_Decorator', 'My/Form/Decorator',
> 'decorator');
> > $form->addDisplayGroupPrefixPath('My_Form_Decorator',
> 'My/Form/Decorator');"
> >
> > These are for auto loading your classes, the path passed as the second
> parameter will be joined
> > together with other paths
> > on your PHP include path, to find class file referenced, so for example,
> if you have:
> >
> > C:/library on your include path and reference the class
> My_Form_Decorator_Foo, ZF will look
> > for the class at: C:/library/My/Form/Decorator/Foo.php
> >
> > The first argument to the methods above is the prefix you give to your
> classes to name-space
> > them, as per ZF convention, as you can see in the example above:
> My_Form_Decorator_Foo.
> > The second method parameter is the path to resolve these classes.
> >
> > Regarding form input IDs and form name attributes, these can be set via
> setAttrib( 'id', VALUE)
> > and setName('NAME') respectively, so you could pass in some
> > option to your addForm() method that add/changes/updates these
> accordingly?
> >
> > I don't know if any of these will be of help as I am just getting to
> grips with Zend_Form myself.
> >
> > Dan
> >
> >
> > 2009/12/20 Mike A <[email protected]>:
> > > Well I have come to the end of a very long Saturday looking at various
> form
> > > decorator tutorials and references online and in books. Sad to say that
> not
> > > one of them takes the subject of Zend's awful form system and explains
> it
> > > completely, in plain English, a theme running through all Zend
> > > documentation.
> > > What, for example, does the sample at
> http://devzone.zend.com/article/3450
> > > mean by
> > > "$form->addElementPrefixPath('My_Form_Decorator', 'My/Form/Decorator',
> > > 'decorator');
> > > $form->addDisplayGroupPrefixPath('My_Form_Decorator',
> 'My/Form/Decorator');"
> > > when there is no example of a directory structure or the name of a file
> > > saved within a directory structure? Path from where? To where?
> > > I have had to try to explain to some of my guys today that Zend is a
> good
> > > framework after comments like "They're up their own {censored} with
> > > technical self gratification." I would have phrased it differently but
> see
> > > the point. Three of us (each with degrees in computer sciences and me
> with
> > > over 35 years development experience) looked at Matthew's webinar and
> found
> > > it profoundly lacking in step-by-step detail, thus leaving doors of
> > > confusion.
> > > Could someone please point me to a reference that explains in clear
> terms
> > > how to use Zend forms for the very common task (easy in plain PHP) of
> > > producing multiple form inputs with same name but different input tag
> IDs
> > > (without which there would be invalid markup) from this example taken
> from
> > > Keith Pope's book (as a general reference):
> > > <? foreach($this->products as $product): ?>
> > > <div class="productitem clearfix">
> > >  <?=$this->productImage($product->defaultImage, array('class' =>
> > > 'img-center'))->thumbnail(); ?>
> > >  <h4><a href="<?=$this->url(array('productIdent' => $product->ident,
> > >  'categoryIdent' => $this->category->ident),
> > >  'catalog_category_product');
> > > ?>"><?=$this->Escape($product->name); ?></a></h4>
> > >  <p><?=$this->Escape($product->shortDescription); ?></p>
> > >  <p><?=$this->productPrice($product); ?></p>
> > >  <?=$this->Cart()->addForm($product); ?>
> > > </div>
> > > ?>
> > > My thanks in advance...
> > > Mike
> > >
> > >
> > > On 18 Dec 2009 at 21:06, Daniel Latter wrote:
> > >> No problem, we all have them ;).
> > >>
> > >> Matthew Weier O'Phinney has just given a really good webinar on just
> > >> this topic, it takes a bit to wrap your head around, heres a link to
> > >> the recording:
> > >>
> > >> http://www.zend.com/en/resources/webinars/framework
> > >>
> > >> Good luck :)
> > >>
> > >>
> > >>
> > >>
> > >>
> > >>
> > >> 2009/12/18 Mike A <[email protected]>
> > >> >
> > >> > On 18 Dec 2009 at 20:42, Daniel Latter wrote:
> > >> >
> > >> > >
> > >> > > Hi,
> > >> > >
> > >> > > What do you mean " many ids with productid produces validation
> error
> > >> > > "? It is left upto
> > >> > > the coder to set a unique id for each element? What are you trying
> to
> > >> > > do, may be it wil shed more
> > >> > > light?
> > >> > >
> > >> > > Also, if im not mistaken both the examples you refer to are the
> same?
> > >> > > are you trying to
> > >> > > dosomthing like this:
> > >> > >
> > >> > > .. id="producid_11" .. ?
> > >> >
> > >> > Yes - my bad. I used Nabble for the first post, it took out some of
> my
> > >> > text. Then my brain
> > >> > went daft on the required example.
> > >> >
> > >> > By validation I'm referring to markup. As sson as I read your reply
> I
> > >> > realised I had not passed
> > >> > id value to the form. Been at this too long today - 14 hours :(
> > >> >
> > >> > Also, trying to get pretty markup via decorator - it's driving me
> nuts!
> > >> >
> > >> > Many thanks Dan
> > >> >
> > >> > > Thanks
> > >> > > Dan
> > >> > >
> > >> > >
> > >> > > 2009/12/18 Mike A <[email protected]>
> > >> > >   Apologies - my previous post did not format correctly, so I
> > >> > > repeat.
> > >> > >
> > >> > > When constructing a form element I use this...
> > >> > >
> > >> > >  $this->addElement('hidden', 'productId', array(
> > >> > >   'decorators' => array(array('ViewHelper'),
> > >> > >          array('HtmlTag', array('tag' => 'p')),
> > >> > >          ),
> > >> > >  ));
> > >> > >
> > >> > > which formats as html (precisely) this way...
> > >> > >
> > >> > >   <p>
> > >> > >   <input type="hidden" name="productId" value="11" id="productId"
> > >> > > /></p>
> > >> > >
> > >> > >
> > >> > > There are two problems with this. First, many input ids with
> > >> > > "productId" produces a validation
> > >> > > error. Second, mark-up format is wrong. What must I do to produce
> this
> > >> > > (with value added to
> > >> > > id)...
> > >> > >
> > >> > >   <p>
> > >> > >   <input type="hidden" name="productId" value="11" id="productId"
> > >> > > />
> > >> > >   </p>
> > >> > >
> > >> > >   TIA...
> > >> > >
> > >> > >   Mike
> > >> > >
> > >> > >
> > >> >
> > >> >
> > >>
> > >
> >
>
>
>

Reply via email to