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