Controllers

To make it easy to edit and save data, Salsa provides a series of controllers that are called with standard form submissions from users. These calls can also be made inline with scripts or Ajax, depending on the architecture of the application. To use any of the forms below inline, append an 'xml' parameter. This will halt the default redirect, and return back an XML summary of the result of the call.

The Flash Object

It is often useful to print to the screen the last error that happened -- for required fields, etc. To faciliate this, SalsaScript provides the 'flash' object. Here is example of printing out error message:
<?
var message=''+salsa.parseNull(flash.getMessages());
if (message.length>0){ print(message);}
flash.clear();
?>

Save

Accessible via the absolute url "/save" on any node, or via the relative url "save" in any package, the Save controller is the most commonly used controller in the system. It takes parameters that specify the object to save, the key to save to (or '0' for a new item), and then a listing of parameters that are saved to that object. It handles all security methods, and redirects once a method has completed. A successfully entry will redirect to the previous page with either the key that you supplied or a new key (?key=123).

Single object insertions

For example:
<form action="/save">
<input type="hidden" name="object" value="supporter"/>
<input type="hidden" name="key" value="123"/>
...
</form>

Redirects

You can also specify the a redirect parameter to direct people to a specific page upon successful completion. By default, upon error, the Save controller directs the user back to the original page.
...
<input type="hidden" name="redirect" value="http://www.mywebsite.org"/>
...

Multi object insertions

You can enter data into more than one table when submitting a form. In our database architecture, supporter information is entered into the supporter table and relational information is entered into tables as follows supporter_relational table. For example supporter group information is stored in a 'supporter_groups' table, similarly supporter custom field information is stored in a table called 'supporter_custom'. If the information you are entering is new:
....
<input type="hidden" name="object" value="supporter"/>
<input type="hidden" name="key" value="123"/>
...
<input type="hidden" name="link" value="custom"/>
<input type="hidden" name="linkKey" value="0"/>
....
<input type='checkbox' class='checkbox blockInput' value='1' id='f8' name='BOOL2'  >
<input type=hidden name='BOOL2' value='0'/>
...
Here you would be updating a supporter record and adding custom field information Here is another example where you would be entering supporter group information To add group information:
<form action="/save">
<input type="hidden" name="object" value="supporter"/>
<input type="hidden" name="key" value="123"/>
...
<input type="hidden" name="link" value="groups"/>
<input type="hidden" name="linkKey" value="11"/>
....
</form>
The same thing where you are entering information for multiple groups
<form action="/save">
<input type="hidden" name="object" value="supporter"/>
<input type="hidden" name="key" value="123"/>
...
<input type="hidden" name="link" value="groups"/>
<input type="hidden" name="linkKey" value="11"/>

<input type="hidden" name="link" value="groups"/>
<input type="hidden" name="linkKey" value="12"/>

<input type="hidden" name="link" value="groups"/>
<input type="hidden" name="linkKey" value="13"/>
....
</form>

Copy

To copy items, the standard Copy controller is provided
<form action="/copy">
<input type="hidden" name="object" value="supporter"/>
<input type="hidden" name="key" value="123"/>
....
</form>
This will copy supporter 123 and create a new record with the data from that supporter.

Delete

To delete items, the standard Delete controller is provided For example:
<form action="/delete">
<input type="hidden" name="object" value="supporter"/>
<input type="hidden" name="key" value="123"/>
...
</form>
This will delete supporter 123. Please note that this delete is not reversible. The selected object is completely removed from the database and no backup is made. It is essential that you add logic informing the supporter that these removals are final and not undoable.

Email

You can access our tell-a-friend functionality as follows:
<form action="/email">
<input type="hidden" name="object" value="supporter"/>
<input type="hidden" name="key" value="123"/>
...
  <label><em>F</em>irst Name</label>
  <input title="First Name" type="text" name="First_Name" value="" size="25" />

  <label><em>L</em>ast Name</label>
  <input title="Last Name" type="text" name="Last_Name" value="" size="25" />

  <label><em>E</em>mail</label>
  <input title="Email" type="text" name="Email" value="mysupporter@theirorg.org"
    size="25" />
 
  <label>Subject</label>
  <input size=45 name="subject" value="test subject"/>

  <label>Customize your message</label>
  <textarea rows=6 cols=50 name="content">lorem ipsum</textarea>

  <label>Email: </label>
  <div>use comma, space or semi-colon (, ;) to separate your email addresses</div>
  <textarea id="emails" name="to" cols="30" rows="6"></textarea><

  <input type="hidden" name="tell_a_friend_KEY" value="456"/>

  <input type="Submit" value="Spread the Word!">

</form>

A REST based API query would look like this:

http://sample.nodeurl.tld/email?xml&tell_a_friend_KEY=456&to=myfriend@gmail.com&username=xxx&password=xxx&subject=test&from=me@my.org&content=something else

Change the server URL to match the server that your account is on.