Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    ValuesManager.saveData()

    Hi,

    I have the following situation :

    - I have 2 forms that use the same data source and are bound to the same valuesManager.
    - One of the forms uses StaticTextItem fields to display information (read-only)
    - The other form uses TextItem fields to allow user editing the information
    - Both forms contain the same fields (let's say name, phone, etc)

    Both forms are simultaneously displayed to the user ... When I issue a valuesManager.saveData()
    which contain server validation errors, I recuperate those from the response and alter the response.errors
    collection to reflect the validation errors, as follows :

    Code:
      dsResponse.errors['phone'] = 'My error message ...';
    My problem is the following :

    The DynamicForm with the StaticTextItem fields gets its fields decorated with the error messages,
    instead of the other DynamicForm with the TextItem fields.

    Is there any way to control this ?

    Thanks for your insight,

    #2
    You can't have two fields on the same DataSource in a ValuesManager, even if one is read-only (you should be seeing a lot of warnings about this). Can you take the form that has StaticTextItems out of the ValuesManager? Or at least the parts of that form that consist of colliding StaticTextItems?

    Comment


      #3
      Indeed,

      having multiple valuesManager (1 per form) resolves my error displaying issue, but now I end up
      having multiple valuesManagers that need to be synchronized whenever one of them changes its
      data ...

      Any suggestions ? I thought ValuesManager were ment to have multiple forms bound to the same
      underlying data, whether be it the same fields or different fields for a given data source.

      I don't seem to be getting warnings in the developer console about this, BTW ...

      Thanks,

      Comment


        #4
        The problem is having two FormItems both potentially contributing a value to a single logical Record. Even though your StaticTextItems are not user-editable, they may be the targets of programmatic logic, could have icons that pop open editing interface, etc and so contribute values in that way.

        If you have the form that has read-only display also bound to the same DataSource, you should see it reacting to saves by updating itself.
        Last edited by Isomorphic; 19 Mar 2012, 14:48.

        Comment


          #5
          So, are you saying that when ValuesManager1.saveData() returns, any other DynamicForm or ValuesManager2
          bound to the same DataSource record primary key should be updated automatically ? Because that
          doesn't seem to be the case.

          Is there a method I should be calling to have ValuesManager2 refreshed upon ValuesManager1's saveData()
          method completing ?

          Thanks for this additional clarification,

          Comment


            #6
            Sorry, double-checking on that, forms will update their values *if that form saves* but will not update values *if another form or component saves*. This is by design as there are a lot of scenarios where this might unexpectedly overwrite data the user's entered data.

            The simplest approach for you is probably to add a callback to the saveData() call that explicitly updates this other display-only form.

            Comment


              #7
              All good. Thanks!

              Comment

              Working...
              X