apostrophecms / apostrophecms/apostrophe
How to programatically insert/update content for a Area field.
- Dominant language
- JavaScript
- Stars
- 4.6k
- Forks
- 650
- Avg merge
- 19h 21m
- Merged PRs (30d)
- 23
Description
If you're unsure how to proceed with a problem and are not sure if it is a bug, please provide some information so we can help you. You can also use the [Apostrophe Discord chat](https://chat.apostrophecms.com/) and [Github Discussions](https://github.com/apostrophecms/apostrophe/discussions/) to ask questions as well.
## Question or comment
Please include as much detail as possible so we can help more quickly.
* What are you trying to do?
Insert/update content of instance with area field inside an handler method.
**Schema**
`fields: {
add: {
........
documentation: {
// label: 'Documentation',
htmlHelp: 'Frame documentation, stored under ”:DOCUMENTATION” slot. Distinct from ”description” or ”...description”',
type: 'area',
options: {
widgets: {
'@apostrophecms/rich-text': {},
'@apostrophecms/image': {},
'@apostrophecms/video': {},
'@apostrophecms/html': {}
}
}
},
....
`
* What have you already tried?
**inside the handler**
`.....
t.documentation.items.push({
metaType: 'widget',
type: '@apostrophecms/rich-text',
aposPlaceholder: false,
content: '
fValue.short_value
',permalinkIds: [],
imageIds: []
});
self.apos.modules[t.type].update(req, t);
....`
or
`....
const area = self.apos.modules['@apostrophecms/rich-text'].newInstance();
const richText = self.apos.modules['@apostrophecms/rich-text'].newInstance();
richText.content = ...
${fValue.short_value}
...;area.items = [ richText ];
t.documentation.items.push(richText);
....`
* Have you already checked the documentation? [A3 documentation](https://v3.docs.apostrophecms.org/) | [A2 documentation](https://v2.docs.apostrophecms.org/)
* Did the docs have a related section but there was not enough information? No related information found.
## Details
**Version of Node.js:**
*PLEASE NOTE: Only stable LTS versions (10.x and 12.x) are fully supported but we will do our best with newer versions.*
v22.5.1
**Server Operating System:**
*The server (which might be your dev laptop) on which Apostrophe is running. Linux? MacOS X? Windows? Is Docker involved?*
MacOs Sonoma 14.5
**Additional context:**
> Add any other context about the problem here. If the problem is specific to a browser, OS or mobile device, specify which.
**Screenshots**
*If applicable, add screenshots to help explain your problem.*
Contributor guide
Research direction
Start by reviewing the Apostrophe v3 area-field and handler documentation, using the schema and handler examples in the issue as the reproduction case. Determine the supported way to insert or update the area content, then document that procedure or clarify the relevant documentation so the example has an unambiguous outcome.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- backend, documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100