|
{% macro render_field(field, label_class='block text-gray-700 font-medium mb-2', input_class='w-full px-4 py-2 border border-gray-300 rounded-md focus:outline-none focus:border-blue-500 focus:ring focus:ring-blue-200', error_class='text-red-600 text-sm mt-1') %} |
|
<div class="mb-4"> |
|
{{ field.label(class=label_class) }} |
|
{{ field(class=input_class, **kwargs) }} |
|
|
|
{% if field.errors %} |
|
<div class="{{ error_class }}"> |
|
{% for error in field.errors %} |
|
<p>{{ error }}</p> |
|
{% endfor %} |
|
</div> |
|
{% endif %} |
|
|
|
{% if field.description %} |
|
<p class="text-gray-500 text-xs mt-1">{{ field.description }}</p> |
|
{% endif %} |
|
</div> |
|
{% endmacro %} |
|
|
|
{% macro render_boolean_field(field, label_class='flex items-center', input_class='h-4 w-4 text-blue-600 border-gray-300 rounded focus:ring-blue-500', error_class='text-red-600 text-sm mt-1') %} |
|
<div class="mb-4"> |
|
<label class="{{ label_class }}"> |
|
{{ field(class=input_class, **kwargs) }} |
|
<span class="ml-2">{{ field.label.text }}</span> |
|
</label> |
|
|
|
{% if field.errors %} |
|
<div class="{{ error_class }}"> |
|
{% for error in field.errors %} |
|
<p>{{ error }}</p> |
|
{% endfor %} |
|
</div> |
|
{% endif %} |
|
|
|
{% if field.description %} |
|
<p class="text-gray-500 text-xs mt-1">{{ field.description }}</p> |
|
{% endif %} |
|
</div> |
|
{% endmacro %} |
|
|
|
{% macro render_submit_button(text='Submit', class='px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors') %} |
|
<button type="submit" class="{{ class }}"> |
|
{{ text }} |
|
</button> |
|
{% endmacro %} |
|
|
|
{% macro render_cancel_button(url, text='Cancel', class='px-4 py-2 bg-gray-200 text-gray-800 rounded-md hover:bg-gray-300 focus:outline-none focus:ring-2 focus:ring-gray-500 focus:ring-offset-2 transition-colors') %} |
|
<a href="{{ url }}" class="{{ class }}"> |
|
{{ text }} |
|
</a> |
|
{% endmacro %} |
|
|