Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactive forms #934

Merged
merged 10 commits into from Aug 26, 2020
Merged

Conversation

SchrodingersGat
Copy link
Member

Adds functionality to make modal forms more "reactive" to user input

Callbacks

Adds the ability to attach a callback function to any named field. When the value of that field is changed, the callback is called (with the new value).

Update Field Options

Adds helper functions to change the provided options in a given modal form field.


With these two new features, the following sequence can be allowed:

  1. User changes selected value in a field
  2. The new value is used to perform an AJAX query, resulting in a list of values being returned
  3. The list of values is formatted and creates new <option> elements for a different field

…anged

- Attach callback function
- Add a function to retrieve a field by name
- The default DRF behaviour throws errors if the supplied query params do not conform to the limit_choices_to field
- This is non optimum! Don't want to have to handle these cases
- Do the filtering ourselves!
- Quick way to ensure the supplier part objects are printed the same way
- Use the pythonic back-end to render the data
@SchrodingersGat
Copy link
Member Author

@eeintech this implementation is super simple, and very extensible. If you can find any other forms which would benefit from inter-linking fields, please point them out.

FYI, once the javascript code was setup, this is all it takes to link the particular form fields together:

image

- New function for launching a CreateStockItem form
- Wraps up the previous code improvements into a single function
- Oh, the ease!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant