Skip to content

Commit

Permalink
update readme (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-yin authored Sep 13, 2024
1 parent 4e2be20 commit 2516cb4
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 13 deletions.
Binary file added .github/assets/code.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 7 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,19 @@

</div>

```html
{% load formify %}

<form method="post">

{% csrf_token %}

{% render_form form %}

{% render_submit text='Hello Formify!' variant="primary" %}

</form>
```
![Django Formify Code](.github/assets/code.png)

![Django Formify Demo](.github/assets/formify-demo.jpg)

## Documentation

[Documentation](https://django-formify.readthedocs.io/)

## FAQ

### Django-Formify vs Crispy-Tailwind

1. Django-Formify is a fork of Crispy-Tailwind, the core logic is the same.
2. Django-Formify changed the way of rendering, to make it more flexible and easy to customize.
3. Django-Formify has components built using Django-ViewComponent, which makes the code more reusable and easy to maintain. Developers can also create their own components to fit their needs.
4. Django-Formify updated styles of some widgets such as file input to make them look better with Tailwind CSS.
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Topics

install.md
get_started.md
tags.md
formify_helper.md
layout.md
component_design.md
47 changes: 47 additions & 0 deletions docs/source/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Template Tags

## render_form

This tag can render form or formset.

It will iterate and render all form fields automatically.

## render_submit

This tag is to render the submit button.

You can also add extra variables

```html
{% render_submit text='Sign In' css_class="custom-css" name='action_primary' value='action_primary' %}
```

`render_submit` behavior can be customized by overriding `formify_helper.render_submit` method

Please check [Formify Helper](./formify_helper.md) to learn more.

To use formify_helper attached to the `form` instance, you can pass `form` to the `render_submit` like this:

```html
{% render_submit form text='Hello' css_class="btn btn-primary" %}
```

If you have svg in submit button as indicator, you can use this approach to make your code DRY.

## render_field

In some cases, if you want to render a specific field, you can use this tag.

```html
{% render_field form.email %}
```

You can also override formify_helper variable like this:

```html
{% render_field form.email form_show_labels=False %}
```

## render_form_errors

This tag can render form non-field errors.

0 comments on commit 2516cb4

Please sign in to comment.