apostrophe-schemas
Advanced tools
Comparing version 0.5.61 to 0.5.62
{ | ||
"version": "0.5.61", | ||
"version": "0.5.62", | ||
"name": "apostrophe-schemas", | ||
@@ -4,0 +4,0 @@ "description": "Schemas for easy editing of properties in Apostrophe objects", |
@@ -277,19 +277,32 @@ # apostrophe-schemas | ||
It is also possible to inject some custom markup around a field. Just output the fields "before" a certain point, then the fields "after" it: | ||
You may want to customize the way a particular field is output. The most future-proof way to do this is to use the `custom` option and pass your own macro: | ||
```jinja | ||
{{ schemaFields(fields, { before: 'shoeSize' }) }} | ||
<p>Here comes the shoe size kids!</p> | ||
{{ schemaText('shoeSize', 'Shoe Size') }} | ||
<p>Wasn't that great?</p> | ||
{{ schemaFields(fields, { after: 'shoeSize' }) }} | ||
{% endblock %} | ||
```markup | ||
{% macro renderTitle(field) %} | ||
<fieldset data-name="field.name" class="super-awesome">special awesome title: <input name="field.name" /></fieldset> | ||
{% endmacro %} | ||
{%- block modalBody -%} | ||
<form> | ||
{{ | ||
snippetAllFields(fields, { | ||
custom: { | ||
title: renderTitle | ||
} | ||
}) | ||
}} | ||
</form> | ||
{%- endblock -%} | ||
``` | ||
In addition to `before` and `from`, you may also use `after` and `to`. `before` and `after` are exclusive, while `from` and `to` are inclusive. Combining `before` and `from` let us wrap something around a specific field without messing up other fields or even having to know what they are. | ||
This way, Apostrophe outputs all of the fields for you, grouped into the proper tabs if any, but you still get to use your own macro to render this particular field. | ||
Yes, you can output your own custom markup for fields, provided the markup has the same data attributes and name attributes. | ||
If you want to include the standard rendering of a field as part of your custom output, use the `aposSchemaField` helper function: | ||
Note that you do not need to supply any arguments that can be inferred from the schema, such as the `choices` list for a `select` property, or the widget type of a singleton. The real initialization work happens in browser-side JavaScript powered by the schema. | ||
`aposSchemaField(field)` | ||
This will decorate the field with a `fieldset` in the usual way. | ||
Note that the user's current values for the fields, if any, are added by browser-side JavaScript. You are not responsible for that in your template. | ||
You also need to push your schema from the server so that it is visible to browser-side Javascript: | ||
@@ -296,0 +309,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114403
1048