A full-featured, open-source content management framework built with Node.js that empowers organizations by combining in-context editing and headless architecture in a full-stack JS environment.
Although related to convert this method should not be used
as a substitute. This method is intended as a way for custom
schema fields to gain vision into each other's current contents.
For example, apostrophe-forms might use this method to
determine which form field names should be presented as
choices for a conditional display feature.
Given an $el as passed into a schema field's
populate() method, a levels of 1 and a callback, it will
convert all of the fields present and invoke callback with
(err, data).
If levels is 2 complete data for the parent context is
converted and delivered. For instance, if this field is
a string field nested in an array field, the entire
array is passed to the callback as data. object fields
are handled similarly.
If levels is 3 the data for the next context up is converted
and delivered; if this field is a string nested in an array
nested in the schema of a piece, the data will be for the
entire piece.
If levels is null or completely omitted from the call, the data
for the root context is converted and delivered (the data
for the complete piece).
err may contain an array of errors, however data will
still contain as much information as possible. For instance,
if a required field is missing err will be truthy but
there will still be data worth inspecting in data.
If calling getContextData($el, 2, callback) from a
field that is nested in an array field, be aware that the
array data received may or may not include the particular
array item your field is in. If you need to inspect the
latest values of your own peer fields use a depth of 1
to get them.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Proposed method and docs:
Although related to
convert
this method should not be used as a substitute. This method is intended as a way for custom schema fields to gain vision into each other's current contents. For example,apostrophe-forms
might use this method to determine which form field names should be presented as choices for a conditional display feature.Given an
$el
as passed into a schema field'spopulate()
method, alevels
of1
and a callback, it will convert all of the fields present and invokecallback
with(err, data)
.If
levels
is2
complete data for the parent context is converted and delivered. For instance, if this field is astring
field nested in anarray
field, the entire array is passed to the callback asdata
.object
fields are handled similarly.If
levels
is3
the data for the next context up is converted and delivered; if this field is astring
nested in anarray
nested in the schema of a piece, the data will be for the entire piece.If
levels
is null or completely omitted from the call, the data for the root context is converted and delivered (the data for the complete piece).err
may contain an array of errors, howeverdata
will still contain as much information as possible. For instance, if arequired
field is missingerr
will be truthy but there will still be data worth inspecting indata
.If calling
getContextData($el, 2, callback)
from a field that is nested in an array field, be aware that the array data received may or may not include the particular array item your field is in. If you need to inspect the latest values of your own peer fields use a depth of1
to get them.