Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmiller committed Jul 15, 2016
1 parent ae02b70 commit e61ae3d
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class SimplePathway(pathways.Pathway):

You could access this pathway from e.g. `http:\\localhost:8000\pathway\#\simples\`.

### Steps with multiple isntances of records

Sometimes we may want to add multiple instances of a subrecord at the same time, for example when we're recording multiple allergies. To add a multiple step simply use a MultiSaveStep, for example:

Expand All @@ -74,18 +75,43 @@ class SimplePathway(pathways.Pathway):
)
```

If we want to save multiple types of models on the same page, a step needs a title,
an icon and a template url, that's all. Then in the template you can just insert the forms off the models
e.g.
### Complex steps - more than one subrecord type

If we want to save multiple types of subrecords at the same step, we can do that by simply including the
relevant form templates in a custom step template.

```python
from pathway import pathways
from myapp import models

class SimplePathway(pathways.Pathway):
display_name = 'A simple pathway'
slug = 'simples'
steps = (
pathways.Step(
title='Demographics and Diagnosis',
icon='fa fa-clock',
template='pathways/demographics_and_diagnosis_step.html'
),
)
```

The title and icon are rendered in the header for this step in your pathway, which exist outside the scope of the step template itself. Then all we would need is the template itself:

```html
<!-- pathways/demographics_and_diagnosis_step.html -->
{% include models.Demographics.get_form_template %}
{% include models.Diagnosis.get_form_template %}
```

if we want to also save multiple types of the same model e.g. treatment on this page we can add in a multi save section
using the 'multisave' template tag, then our page will look something like this
#### Complex steps with multiple instances per subrecord

If we need to also save multiple types of the same subrecord e.g. `Treatment` in this step,
we simply use the `multisave` template tag.

```html
{% load pathways %}

{% include models.Demographics.get_form_template %}
{% include models.Diagnosis.get_form_template %}
{% multisave models.Treatment %}
Expand Down

0 comments on commit e61ae3d

Please sign in to comment.