Announce a form which will be used for ajax calls. |
|
| see add, drop, each, edit, input, name, new, publish, remote update | |
<r:form mode='team'><form> <ul> <li><b>select team members</b></li> <li><r:checkbox name='mate_ids' nodes='contacts in site'/></li> <li><r:input type='submit'/></li> </ul> </form></r:form> <h3>drop updates icon, with form</h3> <div do='drop' change='params' d='[id]' do='if' test='param:d'> <r:node where='id eq param:d' in='site'> Change icon to <r:img mode='tiny'/> ? <r:form t_id='[main.id]'> <r:input type='hidden' name='icon_for_id' set_value='[main.id]'/> <r:input type='hidden' name='m_title' set_value='becoming icon for [main.name]'/> <r:textarea name='m_text'/> <input type='submit'/> </r:form> </r:node> <r:else> please drop a node to change the icon <r:icon> <r:img mode='pv'/> <ul do='comments'> <li do='each'> <b do='[title]'/> <b do='[author_name]'/> <div do='{text}'/> </li> </ul> </r:icon> </r:else> </div> |
You can omit the <form> element and it will be added to wrap the content but there are cases where you definitely need both: declare the whole form and place the actual form elements. For example:
<table do='mates'> <tr do='each'><td do='link'/></tr> <tr do='form'><td><form>...</form></td></tr> <tr do='add'><td><r:add_btn/></td></tr> </table>
automatic fields
Whether you use forms in ajax contexts or to update/create new elements without javascript, the necessary fields to create the correct objects and/or to render the proper partials are automatically inserted.
There is one field that is necessary to create any Node: parent_id. When no input or select exists for this field Zafu sets the parent_id to the node context before new.
redirection
If you want the form to redirect after create/update, set the “redir” parameter:
<r:form>... <input type='hidden' name='redir' value='#{zen_path(main, :mode => 'foo')}'/> </r:form>
Yes, you have to use the ”>” text instead of ”>” (amp, ‘g’, ‘t’, ’;’).
You can also use the “mode” parameter to redirect to the node’s page with the given mode.