Sitecore 6 WFFM: How to hide fields? - sitecore

In Web Forms for Marketers, I have a few fields that I am using to pass values to the pipeline processors and to append CSS code to the form.
I don't want these fields to appear on the form. How can I mark a field to be invisible? Right now I am doing this via CSS, but I am quite sure there must be a better way to do so.
Thanks!

You can extend the Single Line Text field class and change the container CSS class to your own CSS class that hides the field and label. You can also add value to that field when the form is loaded through the querystring.

I believe there is a Hidden Field type in WFFM. Could you use that?

Related

Django Model field as formfield in templates

I guess this is a simple question, but I am not being able to find a definitive answer whether this is possible or not.
I have a Model object that is being passed to my template during rendering. While I use most of the Model fields to show their values, I came across a need to show a few of them as formfields (with their respective HTML element like rendered via ModelForms). Can ModelForm class usage be avoided here and simply use the Model's field to be rendered as formfield directly from template?
an example:
class MyModel(models.Model):
month = models.PositiveIntegerField(_('Month'), choices=MONTH_CHOICES)
year = models.PositiveIntegerField(_('Year'))
Now in template based on the above Model example I want to show the year as a value but month as a dropdown with selected current value?
Any pointer appreciated!
Use case:
Imagine a generic list_view like case where you are rendering a queryset. What you have there is object per iteration, however on the list view you want to allow your users to perform some quick editing of few object attributes to avoid forcing them to go to full edit mode (maybe via simple ajax).
No.
As canvassed in the comments, this is not possible. A model, and its fields do not know about forms - that is what forms, and modelforms are for.
The right way to do this is to wrap your model objects with a modelform, which you can adjust (using inheritance) to do whatever you want with the non-form fields, if you wish to make this more transparent.
Creating modelforms in the template means that you have nowhere to process the forms in django. Apparently you want to interface them with some kind of ajax interface, so perhaps this is not a problem for you, but in any case, I fail to see how it would be easier than simply creating the modelforms in the view.

Django, custom fields, to_python, and displaying serialized text as-is in Django admin

I have a complex object that I'm storing serialized in a text field. For most purposes, I want the object pulled from the database to be that complex object. However, when I'm editing it in a form, I just want to see that serialized text in the field.
I tried using the value_to_string function but it appears as if it isn't being called at all when editing the record from with admin.
What do I do so that the raw serialized text shows up in the admin text field?
Since the admin already uses the value of your model field, one option would be re-serializing it for editing...
See also formfield_overrides:
This provides a quick-and-dirty way to override some of the Field
options for use in the admin. formfield_overrides is a dictionary
mapping a field class to a dict of arguments to pass to the field at
construction time.
I'm not sure if it's the same problem, but I figured out a way to change the field value in the admin form before displaying it. I explained how to use a custom widget and an custom admin form in this answer.
Note that the custom widget only helps you to display the value in a different format. It won't parse the input value back to an object, although I believe that would be possible too.

overriding admin field label content in django

I am using admin forms for the CRUD operations. However, I want to add certain characters in the labels generated by the admin. For example, * in case the field is required. How can I accomplish it?
I can directly go into django admin code and add the * in there (in the file contrib/admin/helpers.py in this case) But it is not the right way. How can I do it?
There's no "great" way to do this, so your options will be css (add background img), subclassing form, template tags, or template modification. There are some good answers to this previous question here:
How to render form field with information that it is required

How customize fields in the Django admin interface

I have a model in my Django project with a member which is a char field. Basically data in this field will be entered as comma-separated values.
Without a long-winded explanation of what the overall goal of this is, basically rather than having the admin interface use a simple text field, I'd rather have have some custom HTML for the form so I can just use checkboxes and assemble the values of the checked boxes into a CSV string myself once the form is submitted.
Most of the django customization I was able to find on Google didn't answer my particular problem.
If I understand your question correctly I think you want to search for writing custom widgets. Perhaps start here: http://docs.djangoproject.com/en/dev/topics/forms/

Django admin output extra HTML in ModelSite

Ultimately, I want to add an <iframe> to the display of a particular model on Django's admin page. Django is already rendering the form for this model correctly, but I want to add this <iframe> in addition to Django's form. The src attribute needs to involve the primary key for the currently-displayed record.
I've learned how to properly override the change_form.html template through Django's documentation, and I can add markup to the right block, but I can't figure out how to access the primary key value. (No amount of determined Googling has helped at all.)
Alternatively, is there a direct way to specify that I want to produce extra output in my ModelSite definition?
Overriding "change_form.html" is the right way to go. You can access the current object with
{{ original }}