Class: SearchForm

SearchForm

new SearchForm()

Embodies a SearchForm object. To create SearchForm objects that are allowed in the API, please use the API.form() method.
Source:

Methods

fetch(fields) → {SearchForm}

Restrict the results document to the specified fields
Parameters:
Name Type Description
fields string | array The list of fields, array or comma separated string
Source:
Returns:
- The SearchForm itself
Type
SearchForm
Include the requested fields in the DocumentLink instances in the result
Parameters:
Name Type Description
fields string | array The list of fields, array or comma separated string
Source:
Returns:
- The SearchForm itself
Type
SearchForm

lang(fields) → {SearchForm}

Sets the language to query for this SearchForm. This is an optional method.
Parameters:
Name Type Description
fields string The language code
Source:
Returns:
- The SearchForm itself
Type
SearchForm

orderings(orderings) → {SearchForm}

Sets the orderings to query for this SearchForm. This is an optional method.
Parameters:
Name Type Description
orderings array Array of string: list of fields, optionally followed by space and desc. Example: ['my.product.price desc', 'my.product.date']
Source:
Returns:
- The SearchForm itself
Type
SearchForm

page(p) → {SearchForm}

Sets the page number to query for this SearchForm. This is an optional method.
Parameters:
Name Type Description
p number The page number
Source:
Returns:
- The SearchForm itself
Type
SearchForm

pageSize(size) → {SearchForm}

Sets a page size to query for this SearchForm. This is an optional method.
Parameters:
Name Type Description
size number The page size
Source:
Returns:
- The SearchForm itself
Type
SearchForm

query(query) → {SearchForm}

Sets a predicate-based query for this SearchForm. This is where you paste what you compose in your prismic.io API browser.
Parameters:
Name Type Description
query string | array Either a query as a string, or as many predicates as you want. See Prismic.Predicates.
Source:
Returns:
- The SearchForm itself
Type
SearchForm
Example
form.query(Prismic.Predicates.at("document.id", "foobar"))

ref(ref) → {SearchForm}

Sets a ref to query on for this SearchForm. This is a mandatory method to call before calling submit(), and api.form('everything').submit() will not work.
Parameters:
Name Type Description
ref Ref The Ref object defining the ref to query
Source:
Returns:
- The SearchForm itself
Type
SearchForm

set(field, value) → {SearchForm}

Set an API call parameter. This will only work if field is a valid field of the RESTful form in the first place (as described in the /api document); otherwise, an "Unknown field" error is thrown. Please prefer using dedicated methods like query(), orderings(), ...
Parameters:
Name Type Description
field string The name of the field to set
value string The value that gets assigned
Source:
Returns:
- The SearchForm itself
Type
SearchForm

submit(callback)

Submits the query, and calls the callback function.
Parameters:
Name Type Description
callback function Optional callback function that is called after the query was made, to which you may pass three parameters: a potential error (null if no problem), a Response object (containing all the pagination specifics + the array of Docs), and the XMLHttpRequest
Source: