Repository: stephenmcd/mezzanine

Issue:
FORMS_USE_HTML5 causes a migration
Setting `FORMS_USE_HTML5 = True` will trigger a migration, because the `editable` attribute for the placeholder field in [models.py](https://github.com/stephenmcd/mezzanine/blob/master/mezzanine/forms/models.py#L68) depends on it.

It looks like the purpose behind the conditional `editable` is to easily show/hide the placeholder in the `Field` inline admin. Is that correct, or am I missing something?



Discussion:
That's right - we should change it to not use `editable` and find a different way to show/hide the field.

Seems like we can use `ModelAdmin.get_fields()` to check for `USE_HTML5` there. [Docs](https://docs.djangoproject.com/en/1.8/ref/contrib/admin/#django.contrib.admin.ModelAdmin.get_fields).

Or even just set `fieldsets` on `FieldAdmin`? That would be consistent with a lot of other admin classes we have.

Or maybe something like this?

``` python
field_fields = [all fields minus placeholder]
if html5:
   field_fields.insert('placeholder')
```

Then just assign that to `FieldInlineAdmin.fields`.

I like the `get_fields()` option because we can dynamically get all fields with a call to `super`, instead of manually defining each of them. Plus, we gotta start using those Django 1.7+ goodies, hahaha.

Oh yeah, that's what I meant :-)

I meant `fields` not `fieldsets` I mean.

I guess I like that better than overriding the method since that's how we've done it everywhere else, and that's the main API that Django offers.

Got it. Will get a PR ready.

Any update on this?


Resolving patch:
diff --git a/mezzanine/forms/admin.py b/mezzanine/forms/admin.py
--- a/mezzanine/forms/admin.py
+++ b/mezzanine/forms/admin.py
@@ -35,6 +35,10 @@
 form_fieldsets.insert(1, (_("Email"), {"fields": ("send_email", "email_from",
     "email_copies", "email_subject", "email_message")}))
 
+inline_field_excludes = []
+if not settings.FORMS_USE_HTML5:
+    inline_field_excludes += ["placeholder_text"]
+
 
 class FieldAdmin(TabularDynamicInlineAdmin):
     """
@@ -42,6 +46,7 @@ class FieldAdmin(TabularDynamicInlineAdmin):
     add dynamic "Add another" link and drag/drop ordering.
     """
     model = Field
+    exclude = inline_field_excludes
 
 
 class FormAdmin(PageAdmin):
diff --git a/mezzanine/forms/migrations/0005_auto_20151026_1600.py b/mezzanine/forms/migrations/0005_auto_20151026_1600.py
new file mode 100644
--- /dev/null
+++ b/mezzanine/forms/migrations/0005_auto_20151026_1600.py
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('forms', '0004_auto_20150517_0510'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='field',
+            name='placeholder_text',
+            field=models.CharField(max_length=100, verbose_name='Placeholder Text', blank=True),
+        ),
+    ]
diff --git a/mezzanine/forms/models.py b/mezzanine/forms/models.py
--- a/mezzanine/forms/models.py
+++ b/mezzanine/forms/models.py
@@ -65,7 +65,7 @@ class Field(Orderable):
     default = models.CharField(_("Default value"), blank=True,
         max_length=settings.FORMS_FIELD_MAX_LENGTH)
     placeholder_text = models.CharField(_("Placeholder Text"), blank=True,
-        max_length=100, editable=settings.FORMS_USE_HTML5)
+        max_length=100)
     help_text = models.CharField(_("Help text"), blank=True, max_length=100)
 
     objects = FieldManager()


Test patch: