create
or update
actions.
<form method="POST" action="<%= url_for :action => :create %>"> </form>
Add a \<ul>
tag inside your form. To break your fields into multiple groupings, include one \<ul>
tag to contain each group as described above.
Note: to append a label to a group of fields, use the
\
tag to apply styling appropriate for each platform.
Add one \<li>
tag inside the \<ul>
tag for each input field. You must adhere to the syntax found in the examples below to access the natively-styled form elements for each platform.
Note: each check-box and radio button will need to be contained inside its own list item. Further discussion of the formatting can be found later in this document.
To include a “submit” button, immediately below the last closing \</ul>
tag and immediately above the closing \</form>
tag.
Note: the button should not be contained inside an
\<li>
tag, and must have thestandardButton
class to be appropriately styled.
<input type="submit" class="standardButton" value="Create" />
Creating a custom “Edit” Form
You can create native-styled forms by organizing form fields in one or more unordered lists inside a view’s Add a Note: to append a label to a group of fields, use the When creating an edit form, it should include a hidden field that contains the id of the object being edited. Add one Note: each check-box and radio button will need to be contained inside its own list item. Further discussion of the formatting can be found later in this document. To include a form submission button, immediately below the last closing Note: the button should not be contained inside an In native iPhone applications, text fields display a placeholder attribute, rather than the standard label/value pair used on WiMo and Android devices. To display the label for text fields properly on all supported devices, follow the following steps when adding or editing a text field:
Apply the Call the placeholder method inside the text field input tag and include the desired placeholder text as an argument. The text field input tag should contain an embedded ruby tag calling the placeholder method to display placeholder text only on the iPhone. The placeholder method only returns the placeholder attribute when the application is running on an iPhone, since only native iPhone applications use placeholders instead of labels. Checkboxes should be used to allow the user to distinguish between two binary states. On Android and WiMo, checkboxes look like checkboxes. However, traditional checkboxes are not a native component on the iPhone, so to comply with Apple HIG, checkboxes are instead displayed as switches labeled with the diametrically opposed states ‘on/off.’ The custom style can be overridden on the iphone by redefining div#content form input[type=“checkbox”] as follows: Android and iPhone applications display stylized radio buttons that match those used in the native interface. Note that on the iPhone, a selected radio button will be marked with a check-mark. WiMo applications utilize the default radio button styles. The style-sheets included in your Rhodes applications customize the style of the selection box element displayed on the form. Select boxes make use of the device’s native selection components and cannot be modified. Although textareas are styled in css for each device, by convention, each textarea tag must include attributes for the number of rows and columns. The recommended values for rows and columns can be found below. Additionally, each textarea tag must have both an opening If your application is targeting Windows Mobile devices, include the Buttons involved in form submission should be created as input tags, type submit. Buttons should not be contained inside an Links / buttons used to perform actions related to the form but not involved in form submission (e.g., Delete, Cancel) should be located in the top toolbar instead.“content” \<div>
.
Include a form tag inside the \
<form method="POST" action="<%= url_for :action => :create %>">
</form>
\<ul>
tag inside your form. To break your fields into multiple groupings, include one \<ul> tag to contain each group as described above.\
tag to apply styling appropriate for each platform.<input type="hidden" name="id" value="<%= @model_name.object %>"/>
\<li>
tag inside the \<ul>
tag for each input field. You must adhere to the syntax found in the examples below to access the natively-styled form elements for each platform.\</ul>
tag and immediately above the closing \</form>
tag.
tag, and must have the standardButton
class to be appropriately styled.<input type="submit" class="standardButton" value="Create" />
Form fields
Text fields
fieldLabel
class to the textfield label. The fieldLabel
class prevents the label from being displayed on the iPhone by setting the display property to “none
”.<ul>
<li>
<label for="thing[name]" class="fieldLabel">Name</label>
<input type="text" name="thing[name]" <%= placeholder( "Name" ) %> />
</li>
<li>
<label for="thing[desc]" class="fieldLabel">Desc</label>
<input type="text" name="thing[desc]" <%= placeholder( "Desc" ) %> />
</li>
</ul>
Checkboxes/Switches
<ul>
<li>
<label for="todo[description1]">C2</label>
<input type="checkbox" name="todo[description1]" />
</li>
<li>
<label for="todo[description2]">C2</label>
<input type="checkbox" name="todo[description2]" />
</li>
</ul>
div#content form input[type="checkbox"]{
background: none;
-webkit-appearance: checkbox; #explain webkit appearance
width:20px;
}
Radio Buttons
<h4 class="groupTitle">Current status</h4>
<ul>
<li><label for="task[status]">Not started</label>
<input type="radio" name="task[status]" value="new"/>
</li>
<li><label for="task[status]">In progress</label>
<input type="radio" name="task[status]" value="current"/>
</li>
<li><label for="task[status]">Finished</label>
<input type="radio" name="task[status]" value="complete"/>
</li>
</ul>
Select boxes
<h4 class="groupTitle">Select</h4>
<ul>
<li>
<select name="cars">
<option value="volvo" selected>Please select</option>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="fiat">Fiat</option>
<option value="gremlin">Gremlin</option>
</select>
</li>
</ul>
Text areas
\<textarea>
and closing \</textarea>
tag - self-closing textarea tags will not be displayed properly in your application.<h4 class="groupTitle">Textarea</h4>
<ul>
<li class="textarea">
<textarea rows="5" cols="30" ></textarea>
</li>
</ul>
textarea
class on any \<li>
tags containing a text area to ensure that the list item is the proper height.Buttons
\<li>
tag, and must have the standardButton
class to be appropriately styled.<input type="submit" class="standardButton" value="Create"/>
\<button>
elements are not supported in Windows Mobile and BlackBerry platforms.