1
whereray
How to mark Required XoopsForm Element?
  • 2003/12/14 16:27

  • whereray

  • Just popping in

  • Posts: 29

  • Since: 2003/4/16


I want to show a "*" beside each required XOOPS form element. Here is my code in the template file:

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

Can anybody tell me why it does work and what is the correct code?

Thanks!

2
whereray
Re: How to mark Required XoopsForm Element?
  • 2003/12/15 7:17

  • whereray

  • Just popping in

  • Posts: 29

  • Since: 2003/4/16


Anybody there?

3
skalpa
Re: How to mark Required XoopsForm Element?
  • 2003/12/15 13:21

  • skalpa

  • Quite a regular

  • Posts: 300

  • Since: 2003/4/16


Quote:
Can anybody tell me why it does work and what is the correct code?


1) It doesn't work because the XOOPS function that transforms the form elements to template variables doesn't take care of the "required" flag (you only have access to name / caption / body and hidden).
2) There is no correct code

The only solution I would have for now would be:
- Wait for 2.1 next year (this will be possible, but I changed almost everything in the form framework so I can't just tell you to grab the modification from the CVS tree)
- If you're doing your own module, implement a XoopsForm child class, overload the assign() method, and use your class instead of XoopsThemeForm or whatever you use

Skalpa.>

4
Herko
Re: How to mark Required XoopsForm Element?
  • 2003/12/15 13:42

  • Herko

  • XOOPS is my life!

  • Posts: 4238

  • Since: 2002/2/4 1


Skalpa, I don't think he's into PHP programming much (judging by his question). And since the only thing that needs to be added is a '*', that shouldn't be too hard.

What module are you using? The contact us module, or the Liaise module??

Herko

5
whereray
Re: How to mark Required XoopsForm Element?
  • 2003/12/16 7:07

  • whereray

  • Just popping in

  • Posts: 29

  • Since: 2003/4/16


I am using the contact us module. In fact I add more fileds in the contact form and want to show "*" to identify the required fields.

As you can see, I am not a php coder. XOOPS dev team should think of moving Required attribute from XoopsForm to XoopsFormElement. This is really sth related to the element. And then I can easily show the "*" mark by querying each element's Required attribute.

6
PureLuXus
Re: How to mark Required XoopsForm Element?
  • 2003/12/16 16:14

  • PureLuXus

  • Not too shy to talk

  • Posts: 116

  • Since: 2002/1/3 2


try liaise
and add simply a "*" after the field name

Login

Who's Online

160 user(s) are online (101 user(s) are browsing Support Forums)


Members: 0


Guests: 160


more...

Donat-O-Meter

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

Latest GitHub Commits