sisyphus icon indicating copy to clipboard operation
sisyphus copied to clipboard

Allow persisting fields by ids

Open twolfson opened this issue 9 years ago • 3 comments

I have a form which has some fields with editable default values that other fields inherit from. For example:

<input id="default_subject" />
<input id="subject_1" name="subject_1"/>
<script>
  // When our default is updated
  $('#default_subject').on('change', function handleUpdate () {
    // Update the `subject_1` value
    var defaultVal = $('#default_subject').val();
    $('#subject_1').val(defaultVal);
  });
</script>

These default values are UI only as they are not required by the server. As a result, we don't name them so they don't get sent. However, they are editable by the user and we would like to persist them.

To support this in sisyphus, I would like to add id to part of the identifier as we do with form. I have created a fork which achieves this but it is short-sighted as we should really allow for a user to define whatever method they want for identifying a field element:

https://github.com/simsalabim/sisyphus/compare/3d9dd246a4d95fa6f12646a33944c1c370bb1099

twolfson avatar May 22 '15 20:05 twolfson

There were a few restore kinks in that posted link, this should work better:

https://github.com/simsalabim/sisyphus/compare/c7e9c9e

twolfson avatar May 22 '15 21:05 twolfson

@twolfson that's an interesting use case that I've never thought about. Could you please wrap it up as a PR so I could review and test it?

simsalabim avatar May 26 '15 16:05 simsalabim

Sure thing, one PR coming up.

twolfson avatar May 26 '15 17:05 twolfson