Render Object

To quickly render forms and objects to the page, Salsa provides a utility class called 'render'. The Render class automatically generates input form fields based on the database type, and handles all error messages, etc. Combined with the standard controllers, the Render object allows quick and easy public form generation.

render.input(object, field, value)

<?=render.input("supporter", "Email", 
    "type your email address")?>
Will generate this HTML:
<input title="Email" type="text" id="supporter.Email" name="Email" class=""
    value="type your email address" size="25" />

render.inputs(object, key, includes, required, labels, helpText)

<?=render.inputs("supporter",
	0, // this will be a new supporter, but if a saved object is used,
	   // the inputs will be prepopulated with the existing object's values
	["First_Name", "Last_Name", "Zip", "Email"],
	["Email"],
	["First", "Last", "Postal Code", "Your Email Address"], // optional labels
	["This is your first name", "This is your last name", null, null])?>
Generates this HTML:
<div class="formRow">
    <label for="First_Name">First</label>
    <span class="helpText" id="First_Name.helpText">This is your first name</span>
    <input title="First Name" type="text" id="supporter.First_Name"
        name="First_Name" class="" value="" size="25" />
</div>
<div class="formRow">
    <label for="Last_Name">Last</label>
    <span class="helpText" id="Last_Name.helpText">This is your last name</span>
    <input title="Last Name" type="text" id="supporter.Last_Name"
        name="Last_Name" class="" value="" size="25" />
</div>
<div class="formRow">
    <label for="Zip">Postal Code</label>
    <input title="Zip Code" type="text" id="supporter.Zip"
        name="Zip" class="" value="" maxlength="10" />
</div>
<div class="formRow">
    <label for="Email">Your Email Address</label>
    <input title="Email" type="text" id="supporter.Email"
        name="Email" class="" value="" size="25" />
</div>

render.supporter(includes, required, key) This method is useful for public-facing pages which require a supporter_KEY. For instance, if you want a user to sign up to attend an event, you will want to collect their information if it's not already known.

<?=render.supporter(new Array("First_Name", "Last_Name", "Email"),
	new Array("Email"))?>
If there is no existing supporter_KEY, this will generate a signup form with the included fields. If the user already has a supporter_KEY, only a hidden field specifying the supporter_KEY will be generated.