Demystifying Form logic

Dont create your support topics here! No new topics with questions allowed!

Moderator: crythias

Forum rules
Dont create your support topics here! No new topics with questions allowed!
Post Reply
crythias
Moderator
Posts: 10169
Joined: 04 May 2010, 18:38
Znuny Version: 5.0.x
Location: SouthWest Florida, USA
Contact:

Demystifying Form logic

Post by crythias »

"How can I change how a value is stored in a form?"

First, this information is not OTRS specific, and I'm only presenting the information for educational/informational purposes. It is by default outside the scope of OTRS (in general) because it's about how web forms work.

(I admit that what I will show you is incredibly simplified for demonstration purposes.)

You have a form. It has basic components:
a start, inputs, and a finish:
<form name="formName" action="html_form_action.asp" method="put">
Username: <input type="text" name="user" />
<input type="submit" value="Submit" />
</form>

The input type indicates the manner in which the form gets information from the user. The name is the field that holds the value. If you stopped there, you have enough basic information to address any form logic.

Want to preload a field's value? Just add value="Default value here" to the input.

Want to have a value that's always stored? <input type="hidden" name="hiddenfieldname" value="dummyvalue">

"What kind of types can you use?"
button
checkbox
file
hidden
image
password
radio
reset
submit
text

"What about Drop Down boxes?"
<select name="fieldname">
<option value="storevalue">Display information</option>
<option value="storevalue2">Display information</option>
</select>

"What if I want the first to be empty?"
<option value=""></option>

"What if I want the display information to be the value?"
<option>Display information</option>

"How do I pre-check a checkbox?"
<input type="checkbox" checked="true">

"How do I group a radio list?"
<label><input type="radio" name="radiogroupname">Entry1</label>
<label><input type="radio" name="radiogroupname">Entry2</label>

"Why did you surround the radio input with label?"
So you can click the name to make the itty bitty radio button get checked.

"What's the difference between disabled and readonly?"
http://kreotekdev.wordpress.com/2007/11 ... rm-fields/
Basically, disabled entries are skipped everywhere, including form processing, just like unchecked checkboxes.
Readonly entries are not skipped.

"What's with input type=image?"
It's mostly for returning where on the image it has been clicked, like image mapping.

Hope this helps.
OTRS 6.0.x (private/testing/public) on Linux with MySQL database.
Please edit your signature to include your OTRS version, Operating System, and database type.
Click Subscribe Topic below to get notifications. Consider amending your topic title to include [SOLVED] if it is so.
Need help? Before you ask
Post Reply