2008年8月9日星期六

[fw-webservices] Struggling to get zend form ini

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?


--
View this message in context: http://www.nabble.com/Struggling-to-get-zend-form-ini-tp18906577p18906577.html
Sent from the Zend Web Services mailing list archive at Nabble.com.

没有评论: