Hi everyone,
I have a node, let's call it <userid> (datatype string), which uses the
default text widget. When users are completing the relevant form, I would
like to autofill <userid> with the {{user.username}} value (but to still
allow users to change the value).
I've been trying to avoid writing a new widget to handle this scenario and
instead use the existing text widget viewmodel and template. I'm
successfully able to target the correct node by using knockout if/ifnot
bindings
e.g.:
<!-- ko if: node.nodeid == "a72bbb27-bd5d-11e9-9b8f-94659cf754d0" -->
...
<!-- /ko -->
<!-- ko ifnot: node.nodeid == "a72bbb27-bd5d-11e9-9b8f-94659cf754d0" -->
<input type="text" data-bind="textInput: value, attr:
{placeholder: placeholder, maxlength: maxLength, disabled: disabled},
style: {width: width}" class="form-control input-lg widget-input">
<!-- /ko -->
However, each attempt I make at the custom input fails (using either value
or textInput data-binds). It's seemingly easy to make the correct username
appear in the form field when the card loads (by setting params.value to
{{user.username}}) but every time I click Add on the form, the tile save
function fails validation (500 error), so I'm not actually passing the
value correctly or it's getting set/unset at the wrong times or in the
wrong order. As a sanity check I've also tried a simple
data-bind="textInput: userName..." in the template and then this.userName =
ko.observable('abc'); in the textwidget viewmodel, but while abc appears in
the field, I get the same 500 error upon submit. Even when I manually
delete the field and type something new, the form fails. I should note that
the card has multiple text widgets on it.
I'm fairly new to knockout, so I could be attacking this all wrong or
missing something fundamental. Any ideas for how this could be done?
(Trying to avoid editing the resource model...but maybe that can't be
avoided).
Thanks!
Angela
--
-- To post, send email to [email protected]. To unsubscribe, send
email to [email protected]. For more information,
visit https://groups.google.com/d/forum/archesproject?hl=en
---
You received this message because you are subscribed to the Google Groups
"Arches Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/archesproject/3d81849c-4ae3-494c-8b85-9235b6f9ea5d%40googlegroups.com.