1
ultimike
Accessing form element
  • 2004/10/19 15:12

  • ultimike

  • Just popping in

  • Posts: 13

  • Since: 2004/4/21


Good morning,

I'm trying to customize a smarty template and am having a seemingly simple problem.

My template is currently using the standard loop around form elements to display a form:

<!-- start of form elements loop -->
    <{foreach 
item=element from=$contribute_form.elements}>
      <{if 
$element.hidden != true}>
      <
tr>
        <
td class="head"><{$element.caption}></td>
        <
td class="<{cycle values="even,odd"}>"><{$element.body}></td>
      </
tr>
      <{else}>
      <{
$element.body}>
      <{/if}>
    <{/foreach}>
    <!-- 
end of form elements loop -->


I'd like to be able to customize the look of the form and I want to write my own HTML while accessing each form element separatly (not in a loop).

I tried the following code and it isn't working:

<table cellpadding="0" cellspacing="0" border="0" width="240">
  <
tr>
    <
td class="" width="90"><{$contribute_form.firstname_text.caption}>:</td>
    <
td class="" width="150"><{$contribute_form.usersFirstName.body}></td>
  </
tr>
</
table>


Am I not accessing the form elements correctly? Can anyone set me straight?

Thanks in advance,
-mike

2
Mithrandir
Re: Accessing form element

Try something along the lines of
<table cellpadding="0" cellspacing="0" border="0" width="240">
  <
tr>
    <
td class="" width="90"><{$contribute_form.elements.firstname_text.caption}>:</td>
    <
td class="" width="150"><{$contribute_form.elements.usersFirstName.body}></td>
  </
tr>
</
table>

The elements are in a sub-array to $contribute_form, called "elements"

Otherwise, turn on Smarty debug and see, how $contribute_form is structured

3
ultimike
Re:Accessing form element
  • 2004/10/20 3:13

  • ultimike

  • Just popping in

  • Posts: 13

  • Since: 2004/4/21


Mithrandir,

Thanks for the clue - I got it worked out - the correct code is:

<table cellpadding="0" cellspacing="0" border="0" width="240">
  <
tr>
    <
td class="" width="90"><{$contribute_form.elements.usersFirstName.caption}>:</td>
    <
td class="" width="150"><{$contribute_form.elements.usersFirstName.body}></td>
  </
tr>
</
table>


My biggest problem was actually that I didn't know that smarty debugging is presented in a separate browser pop-up window - the popup blocker in Firefox was preventing it from opening and I never realized it!

Thanks for your help.

-mike

Login

Who's Online

178 user(s) are online (118 user(s) are browsing Support Forums)


Members: 0


Guests: 178


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits