b:form

<b:form>...</b:form>

Create a new page or edit an existing page

You can use this tag to create forms that will create a new page or edit an existing page.

To create input field for a control, use <b:form.field /> tag. Bildy will handle the data from these fields and create new or edit existing content. You may also include common HTML <input /> tags in your <b:form> but Bildy won't automatically handle data submitted from them.

To submit the form, you have to manually create the submit button (or Ajax call) for it. Input In addition to the controls you want to have in your form, you will have to create the submit button. See the examples.

Expert tip: for more flexible and powerful handling of forms, you can create HTML forms manually and use the Bildy PHP API to save the data.

b:form tags

b:form.field

<b:form.field />
Creates an input control for a field inside a form

b:rule

<b:rule />
Sets a validation rule for a form field

Attributes

If you use any other attributes that are not on this list, or attributes action or method, they are transferred to the actual form HTML element. This is useful for example for setting the class or id of the form.

datamodel

Data model that the form will use to insert or edit data.

name

Defines the variable name to use inside the tag to refer to controls of the data model.

You can use any name except any of the reserved names.

edit

(optional)

Id number for the data being edited. If edit attribute is used, the form will load the data that the id refers to and updates it. If edit attribute is omitted, the form inserts new page.

sendto

(optional)

Target URL of the form. The current page will be used by default, if sendto attribute is not set.

If this attribute is set to other than the current page, the targeted URL must handle the form. Please note that the attributes defined in the <b:form> on the targeted handler page will decide which parent is used and what page is edited or if a new page is created.

parent

(optional)

Path to the "folder" the content will be saved into. If parent attribute is left out or empty, the current page will be used as the parent. Using a single slash "/" as the parent will place new content to the site root.

Examples

Basic form for inserting data

Here's an example of a basic form for inserting new content.

Here we would have a blog post and under that a list of comments for that post and last a form where users can insert their own comments.

<!-- The blog post -->
<h1><b:page.topic /></h1>
<b:page.content />

<!-- discussion -->
<b:get from="comment" name="comment" parent="<b:page.metadata.url/>">
   <h3><b:comment.sender /></h3>
   <p><b:comment.comment /></p>
</b:get>

<!-- new comment -->
<b:form datamodel="comment" name="newcomment">
   <label>Your name: <b:newcomment.sender /></label>
   <label>Message: <b:newcomment.comment /></label>

   <!-- Bildy won't automaticall handle this information -->
   <input type="hidden" name="previouspage" value=" />

   <!-- Submit button for sending the form to the server -->
   <input type="submit" value="Post this comment" />
</b:form>

More advanced form

This form would place the new content under the current page but the data will be sent elsewhere to be handled.

The targeted page has to have a similar form to handle the data.

Later Bildy will have a handler tag so that no form will be needed on the target page.

<b:form datamodel="comment" 
    name="newcomment"
    sendto="/blog/preview.php"
    parent="<b:page.metadata.url/>">
   <label>Your name: <b:newcomment.sender /></label>
   <label>Message: <b:newcomment.comment /></label>
   <input type="submit" value="Preview this comment" />
</b:form>

Editing form

This form edits the contents of the current page.

<h2>Edit</h2>
<b:form datamodel="page" name="editpage" edit="<b:page.metadata.id />">
   <label>Topic: <b:editpage.topic /></label>
   <label>Content: <b:editpage.content /></label>
   <input type="submit" value="Save changes" />
</b:form>