@@ -54,7 +54,22 @@ Note that the form pre-population mechanism is the `obj=movie` part.
5454
5555## Rendering the extended movie form
5656
57- Let's create the ` templates/movie_form.html ` template:
57+ First, let's edit the ` templates/macros/fields.html ` template to add the a new macro in order to render the custom field:
58+
59+ ``` jinja2
60+ {% macro render_area_field(field) %}
61+ <div class="form__group">
62+ {{ field.label(class_="form__label") }}
63+ {{ field(rows=4, class_="form__field", style="resize: none") }}
64+
65+ {%- for error in field.errors %}
66+ <span class="form__error">{{ error }}</span>
67+ {% endfor %}
68+ </div>
69+ {% endmacro %}
70+ ```
71+
72+ And then create the ` templates/movie_form.html ` template:
5873
5974``` jinja2
6075{% from "macros/fields.html" import render_text_field, render_area_field %}
@@ -90,6 +105,32 @@ Let's create the `templates/movie_form.html` template:
90105{% endblock %}
91106```
92107
108+ Finally we can update the anchor tags in the ` templates/movie_details.html ` template since we now can edit the fields:
109+
110+ ``` diff
111+ ...
112+ {% else %}
113+ <p><a href="{{ url_for('pages.watch_today', _id=movie._id) }}" class="watched__link">Not watched yet</a></p>
114+ {% endif %}
115+ - <a class="movie__edit" href="#">Edit {{ pencil("pencil") }}</a>
116+ + <a class="movie__edit" href="{{ url_for('pages.edit_movie', _id=movie._id) }}">Edit {{ pencil("pencil") }}</a>
117+ </div>
118+ </div>
119+ <div class="header__row">
120+ ...
121+ ```
122+
123+ ``` diff
124+ ...
125+ {% if movie.description %}
126+ <p class="movie__description">{{ movie.description }}</p>
127+ {% else %}
128+ - <p class="movie__description">No description yet. <a class="link" href="#">Add one?</a></p>
129+ + <p class="movie__description">No description yet. <a class="link" href="{{ url_for('pages.edit_movie', _id=movie._id) }}">Add one?</a></p>
130+ {% endif %}
131+ ...
132+ ```
133+
93134Also nothing new here!
94135
95136Note that our custom WTForm field is identical to the ` TextAreaField ` , except when it comes to receiving form data and putting it in our Python object. Everything else behaves the same way as the parent class.
0 commit comments