Dynamic options.addFields in beforeConstruct not working Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!How the single threaded non blocking IO model works in Node.jsHow to build dynamic query by binding parameters in node.js-sql?Following tutorial - stuck on adding new templates under apostrophe-pages in app.jsunable to save image in widget apostropeCkeditor plugin configuration not workingScrapping dynamic data of a web page in nodejsIssue with displaying the image in an Apostrophe css widgetLoad widget dynamicallyOdoo REST API full response of relational modelHow to set baseUrl (also for apostrophe-multisite)
Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?
Does the Black Tentacles spell do damage twice at the start of turn to an already restrained creature?
Tannaka duality for semisimple groups
Why not use the yoke to control yaw, as well as pitch and roll?
Constant factor of an array
Why are vacuum tubes still used in amateur radios?
How can I prevent/balance waiting and turtling as a response to cooldown mechanics
Simple Line in LaTeX Help!
Google .dev domain strangely redirects to https
In musical terms, what properties are varied by the human voice to produce different words / syllables?
malloc in main() or malloc in another function: allocating memory for a struct and its members
Can two people see the same photon?
Why is it faster to reheat something than it is to cook it?
Resize vertical bars (absolute-value symbols)
"klopfte jemand" or "jemand klopfte"?
What adaptations would allow standard fantasy dwarves to survive in the desert?
What is a more techy Technical Writer job title that isn't cutesy or confusing?
Putting class ranking in CV, but against dept guidelines
Why is a lens darker than other ones when applying the same settings?
What does the writing on Poe's helmet say?
Why is std::move not [[nodiscard]] in C++20?
How to ask rejected full-time candidates to apply to teach individual courses?
Did any compiler fully use 80-bit floating point?
Monty Hall Problem-Probability Paradox
Dynamic options.addFields in beforeConstruct not working
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!How the single threaded non blocking IO model works in Node.jsHow to build dynamic query by binding parameters in node.js-sql?Following tutorial - stuck on adding new templates under apostrophe-pages in app.jsunable to save image in widget apostropeCkeditor plugin configuration not workingScrapping dynamic data of a web page in nodejsIssue with displaying the image in an Apostrophe css widgetLoad widget dynamicallyOdoo REST API full response of relational modelHow to set baseUrl (also for apostrophe-multisite)
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I was looking at creating a simple generic reusable text-only widget in apostrophe-cms so I made the module text-only-widgets
.
with the following code
In lib/modules/text-only-widgets/index.js
module.exports =
extend: 'apostrophe-widgets',
label: 'Section Heading',
beforeConstruct: function (self, options) [])
;
In lib/modules/text-only-widgets/views/widget.html
data.widget.sectionHeading
Now I tried using the above widget in one of my pages as below:
<div>
apos.area(data.page, 'aboutUsDescriptionTwo',
widgets:
'text-only':
addFields: [
name: 'sectionDescription', // set these fields dynamically
label: 'Section Description', // set these fields dynamically
type: 'string'
]
)
</div>
As shown in the below image, notice even after passing the addFields with label as Section Description to the text-only widget doesn't override the defaults set in the index.js.
I tried console.log on the options.addFields in index.js but it logs undefined as show below, I also tried few different variations but none works.
node.js apostrophe-cms
add a comment |
I was looking at creating a simple generic reusable text-only widget in apostrophe-cms so I made the module text-only-widgets
.
with the following code
In lib/modules/text-only-widgets/index.js
module.exports =
extend: 'apostrophe-widgets',
label: 'Section Heading',
beforeConstruct: function (self, options) [])
;
In lib/modules/text-only-widgets/views/widget.html
data.widget.sectionHeading
Now I tried using the above widget in one of my pages as below:
<div>
apos.area(data.page, 'aboutUsDescriptionTwo',
widgets:
'text-only':
addFields: [
name: 'sectionDescription', // set these fields dynamically
label: 'Section Description', // set these fields dynamically
type: 'string'
]
)
</div>
As shown in the below image, notice even after passing the addFields with label as Section Description to the text-only widget doesn't override the defaults set in the index.js.
I tried console.log on the options.addFields in index.js but it logs undefined as show below, I also tried few different variations but none works.
node.js apostrophe-cms
add a comment |
I was looking at creating a simple generic reusable text-only widget in apostrophe-cms so I made the module text-only-widgets
.
with the following code
In lib/modules/text-only-widgets/index.js
module.exports =
extend: 'apostrophe-widgets',
label: 'Section Heading',
beforeConstruct: function (self, options) [])
;
In lib/modules/text-only-widgets/views/widget.html
data.widget.sectionHeading
Now I tried using the above widget in one of my pages as below:
<div>
apos.area(data.page, 'aboutUsDescriptionTwo',
widgets:
'text-only':
addFields: [
name: 'sectionDescription', // set these fields dynamically
label: 'Section Description', // set these fields dynamically
type: 'string'
]
)
</div>
As shown in the below image, notice even after passing the addFields with label as Section Description to the text-only widget doesn't override the defaults set in the index.js.
I tried console.log on the options.addFields in index.js but it logs undefined as show below, I also tried few different variations but none works.
node.js apostrophe-cms
I was looking at creating a simple generic reusable text-only widget in apostrophe-cms so I made the module text-only-widgets
.
with the following code
In lib/modules/text-only-widgets/index.js
module.exports =
extend: 'apostrophe-widgets',
label: 'Section Heading',
beforeConstruct: function (self, options) [])
;
In lib/modules/text-only-widgets/views/widget.html
data.widget.sectionHeading
Now I tried using the above widget in one of my pages as below:
<div>
apos.area(data.page, 'aboutUsDescriptionTwo',
widgets:
'text-only':
addFields: [
name: 'sectionDescription', // set these fields dynamically
label: 'Section Description', // set these fields dynamically
type: 'string'
]
)
</div>
As shown in the below image, notice even after passing the addFields with label as Section Description to the text-only widget doesn't override the defaults set in the index.js.
I tried console.log on the options.addFields in index.js but it logs undefined as show below, I also tried few different variations but none works.
node.js apostrophe-cms
node.js apostrophe-cms
asked Mar 22 at 11:44
codincodin
6411926
6411926
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
The addFields
option is at the module level, it controls what fields exist for all instances of this widget. It is not an option that can be passed to individual instances of the widget via apos.area
. Thus you can't do it in this way.
The correct approach is to create a second module which uses extend
to extend the first one and addFields
, at the module level, to add the additional field. Then, in your area, you can offer just one of the two widget types, or both, as is appropriate to your needs.
Thus in addition to lib/modules/text-only-widgets/index.js
you would also have:
// in lib/modules/text-plus-description-widgets/index.js
module.exports =
extend: 'text-only-widgets',
label: 'Section Heading and Description',
addFields: [
name: 'sectionDescription',
label: 'Section Description',
type: 'string'
]
;
And this widget would also have its own widget.html
.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55298892%2fdynamic-options-addfields-in-beforeconstruct-not-working%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
The addFields
option is at the module level, it controls what fields exist for all instances of this widget. It is not an option that can be passed to individual instances of the widget via apos.area
. Thus you can't do it in this way.
The correct approach is to create a second module which uses extend
to extend the first one and addFields
, at the module level, to add the additional field. Then, in your area, you can offer just one of the two widget types, or both, as is appropriate to your needs.
Thus in addition to lib/modules/text-only-widgets/index.js
you would also have:
// in lib/modules/text-plus-description-widgets/index.js
module.exports =
extend: 'text-only-widgets',
label: 'Section Heading and Description',
addFields: [
name: 'sectionDescription',
label: 'Section Description',
type: 'string'
]
;
And this widget would also have its own widget.html
.
add a comment |
The addFields
option is at the module level, it controls what fields exist for all instances of this widget. It is not an option that can be passed to individual instances of the widget via apos.area
. Thus you can't do it in this way.
The correct approach is to create a second module which uses extend
to extend the first one and addFields
, at the module level, to add the additional field. Then, in your area, you can offer just one of the two widget types, or both, as is appropriate to your needs.
Thus in addition to lib/modules/text-only-widgets/index.js
you would also have:
// in lib/modules/text-plus-description-widgets/index.js
module.exports =
extend: 'text-only-widgets',
label: 'Section Heading and Description',
addFields: [
name: 'sectionDescription',
label: 'Section Description',
type: 'string'
]
;
And this widget would also have its own widget.html
.
add a comment |
The addFields
option is at the module level, it controls what fields exist for all instances of this widget. It is not an option that can be passed to individual instances of the widget via apos.area
. Thus you can't do it in this way.
The correct approach is to create a second module which uses extend
to extend the first one and addFields
, at the module level, to add the additional field. Then, in your area, you can offer just one of the two widget types, or both, as is appropriate to your needs.
Thus in addition to lib/modules/text-only-widgets/index.js
you would also have:
// in lib/modules/text-plus-description-widgets/index.js
module.exports =
extend: 'text-only-widgets',
label: 'Section Heading and Description',
addFields: [
name: 'sectionDescription',
label: 'Section Description',
type: 'string'
]
;
And this widget would also have its own widget.html
.
The addFields
option is at the module level, it controls what fields exist for all instances of this widget. It is not an option that can be passed to individual instances of the widget via apos.area
. Thus you can't do it in this way.
The correct approach is to create a second module which uses extend
to extend the first one and addFields
, at the module level, to add the additional field. Then, in your area, you can offer just one of the two widget types, or both, as is appropriate to your needs.
Thus in addition to lib/modules/text-only-widgets/index.js
you would also have:
// in lib/modules/text-plus-description-widgets/index.js
module.exports =
extend: 'text-only-widgets',
label: 'Section Heading and Description',
addFields: [
name: 'sectionDescription',
label: 'Section Description',
type: 'string'
]
;
And this widget would also have its own widget.html
.
answered Mar 22 at 17:43
Tom BoutellTom Boutell
4,68612017
4,68612017
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55298892%2fdynamic-options-addfields-in-beforeconstruct-not-working%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown