Struggling to get zend form ini

7 messages Options
Embed this post
Permalink
andyjab

Struggling to get zend form ini

Reply Threaded More More options
Print post
Permalink
Hi,

I am trying to implement my form using the ini file.

I got the form up fine, specifying it as:

[student_view]
; general form metainformation
add.action = "/dashboard/amendStudent"
add.method = "post"


; title element
add.elements.title.type = "select"
add.elements.title.options.label = "Title"
add.elements.title.options.multiOptions.1 = "Mr"
add.elements.title.options.multiOptions.2 = "Mrs"
add.options.validators.alnum.validator = "NotEmpty"
add.elements.title.options.required = true


; First Name element
add.elements.firstname.type = "Text"
add.elements.firstname.options.label = "First Name"
add.elements.firstname.options.validators.notempty.validator = "NotEmpty"
add.elements.firstname.options.validators.notempty.breakChainOnFailure = true
add.elements.firstname.options.validators.strlen.validator = "StringLength"
add.elements.firstname.options.validators.strlen.options.max = "50"
add.elements.firstname.options.required = true

; Surname Name element
add.elements.surname.type = "Text"
add.elements.surname.options.label = "Surname"
add.elements.surname.options.validators.notempty.validator = "NotEmpty"
add.elements.surname.options.validators.notempty.breakChainOnFailure = true
add.elements.surname.options.validators.strlen.validator = "StringLength"
add.elements.surname.options.validators.strlen.options.max = "50"
add.elements.surname.options.required = true

; Student Code element
add.elements.studentcode.type = "Text"
add.elements.studentcode.options.label = "Student Code"
add.elements.studentcode.options.validators.notempty.validator = "NotEmpty"
add.elements.studentcode.options.validators.notempty.breakChainOnFailure = true
add.elements.studentcode.options.validators.strlen.validator = "StringLength"
add.elements.studentcode.options.validators.strlen.options.max = "50"
add.elements.studentcode.options.required = true


; submit element
add.elements.submit.type = "submit"


But I am struggling to understand how the decorators work with the ini files. I have finally managed (through playing around) got:


; Add the following element decorators to the add form
add.elementDecorators.decorator= "ViewHelper"
add.elementDecorators.error.decorator = "Errors"

; Add a data tag of td to each data field
add.elementDecorators.datatag.type.datatag = "HtmlTag"
add.elementDecorators.datatag.options.tag = "td"


; Add a td tag to each element labelled as a label
add.elementDecorators.label.decorator = "label"
add.elementDecorators.formElements.decorator = "HtmlTag"
add.elementDecorators.formElements.options.tag ="td"

; Add the table <tr> tag to the end of a what it things is a row.
add.elementDecorators.rowtag.type.rowtag = "HtmlTag"
add.elementDecorators.rowtag.options.tag = "tr"


I am trying to transfer:


    ;$form -> setDecorators(array(
    ; 'FormElements',
    ; array('HtmlTag', array('tag' => 'table')),
    ; 'Form',
                ; ));    

to an ini file and have:

; Adds the table parenthesis to the form
add.elementDecorators.formElements.decorator = "HtmlTag"
add.elementDecorators.formElements.options.tag = "table"

But this doesn't work :) Could someone please point me to perhaps an article that breaks this down? Or give me a hint as to what I am doing wrong?



weierophinney

Re: Struggling to get zend form ini

Reply Threaded More More options
Print post
Permalink
-- andyjab <[hidden email]> wrote
(on Saturday, 09 August 2008, 10:07 AM -0700):

> I am trying to transfer:
>
>
>     ;$form -> setDecorators(array(
>     ; 'FormElements',
>     ; array('HtmlTag', array('tag' => 'table')),
>     ; 'Form',
> ; ));    
>
> to an ini file and have:
>
> ; Adds the table parenthesis to the form
> add.elementDecorators.formElements.decorator = "HtmlTag"
> add.elementDecorators.formElements.options.tag = "table"
>
> But this doesn't work :) Could someone please point me to perhaps an article
> that breaks this down? Or give me a hint as to what I am doing wrong?

You're using the wrong configuration key  -- you're trying to set the
form decorators using a configuration key that sets element decorators.

Try this:

    add.decorators.formElements.decorator = "FormElements"
    add.decorators.htmlTag.decorator = "HtmlTag"
    add.decorators.htmlTag.options.tag = "table"
    add.decorators.form.decorator = "Form"

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/
andyjab

Re: Struggling to get zend form ini

Reply Threaded More More options
Print post
Permalink
In reply to this post by andyjab
Yep - that fixed it.

Thank you, thank you, thank you :)

So it was because I had:
add.elementDecorators.formElements.decorator = "HtmlTag"
add.elementDecorators.formElements.options.tag = "table"

formElements settings rather than decorators.form.decorator?

weierophinney

Re: Struggling to get zend form ini

Reply Threaded More More options
Print post
Permalink
-- andyjab <[hidden email]> wrote
(on Saturday, 09 August 2008, 12:40 PM -0700):
> Yep - that fixed it.
>
> Thank you, thank you, thank you :)
>
> So it was because I had:
> add.elementDecorators.formElements.decorator = "HtmlTag"
> add.elementDecorators.formElements.options.tag = "table"
>
> formElements settings rather than decorators.form.decorator?

Actually, it was the elementDecorators rather than just 'decorators'
portion of the key.

--
Matthew Weier O'Phinney
Software Architect       | [hidden email]
Zend Framework           | http://framework.zend.com/
andyjab

Re: Struggling to get zend form ini

Reply Threaded More More options
Print post
Permalink
In reply to this post by andyjab

Well thank you :)

andyjab wrote:
Yep - that fixed it.

Thank you, thank you, thank you :)

So it was because I had:
add.elementDecorators.formElements.decorator = "HtmlTag"
add.elementDecorators.formElements.options.tag = "table"

formElements settings rather than decorators.form.decorator?
ligio

Re: Struggling to get zend form ini

Reply Threaded More More options
Print post
Permalink

andyjab wrote:
Well thank you :)

andyjab wrote:
Yep - that fixed it.

Thank you, thank you, thank you :)

So it was because I had:
add.elementDecorators.formElements.decorator = "HtmlTag"
add.elementDecorators.formElements.options.tag = "table"

formElements settings rather than decorators.form.decorator?
Hi!
Is it possible to add a decorator (or set a property) from a INI config file only for one element?

I want a form like this:

<form action="" method="">
  <div>
    <input name="user">
  </div>
  <div class="submit">
    <input type="submit">
  </div>
</form>
SunWuKung

Re: Struggling to get zend form ini

Reply Threaded More More options
Print post
Permalink
I just would like to second this question.
How can one add a decorator to a single element in a config file?

Thanks for the help.
SWK


ligio wrote:
Hi!
Is it possible to add a decorator (or set a property) from a INI config file only for one element?

I want a form like this:

<form action="" method="">
  <div>
    <input name="user">
  </div>
  <div class="submit">
    <input type="submit">
  </div>
</form>