My graphic design requires all fields in HTML forms to be lowercase. Example:
<tr><th><label for="id_pressure_Hg">pressure Hg</label></th><td><input
id="id_pressure_Hg" type="text" name="pressure_Hg" /></td></tr>
Django forms, however, per default make my labels with capital first letter. Since I have a lot of fields and many forms are created from a model (through a modelform), the "label" attribute is not a viable solution.
Is there a way to modify the function which translates field names into field labels?
you can try this.
example..
in your forms.py
value = forms.CharField(label=u'', widget=forms.TextInput())
in your HTML file.
<ul>
<li>value Value : {{form.value}}</li>
</ul>
you can modify the form.value in your CSS or JQuery. i has this attribute as an input in html.. id=id_value and name=value
Related
I am displaying a list of items using spring webflow.
Each item has an edit button; clicking the button opens up a modal dialog.
If there are 12 items in the list,
I see 12 commas generated in the form path.
How can I avoid generation of commas?
<c:forEach var="note" items="${model.modelname}">
//create a click button for each item
//each click opens up a modal
<div id="modal" class="hidden">
<div class="modal-body-content">
<form:textarea path="textPath" />
</div>
</div>
</c:forEach>
There are several issues at work.
As noted by #dbreaux,
all of your textarea elements are in the same form and have the same id;
this is causing the commas when you post the form.
The element id is supposed to be unique to each element. Your element id is "modal" is not unique. Make it unique. This is not causing the commas.
The name of each textarea is textPath. Since you have multiple elements with one name, you get a comma separated list of values for that element name when you post the form. Each textarea must have a unique name. It appears that you have a unique name for each modal (the loop variable is the modalName). Use that in the name of the textarea.
If you can't give each textarea a unique name, give each textarea its own form. Generate a new form for each modal div.
Here is an example of the solution I proposed in #2 above (Note: I don't have a system running that uses spring tags ATM, this example is untested):
<c:forEach var="note" items="${model.modelname}">
<div id="modal" class="hidden">
<div class="modal-body-content">
<form:textarea path="${note}textPath" />
</div>
</div>
</c:forEach>
It appears that in a single form, you have multiple textarea fields with the exact same field name ("textPath") (and exact same DOM ID, which isn't good either).
If so, I'm not surprised that Spring combines all the values submitted under that single name, with commas separating them. What Java type is your model bean's textPath field? I think if it were an array or maybe List, you might get the values separated out. But that's just a guess.
I m beginer in AngularJS, and i try to do this :
<form ng-repeat="prop in tab">
<input ng-model="prop" type="text">
</form>
{{tab}}
With this code inputs values is ok, but when i edit value the reverse binding to "tab" don't work.
How i can simply do this ?
Thanks for yours tips ;)
If you want to see changes in your html document live you either need to move the expression inside the form tag and change it to {{tab.prop}} or outside the tag but also showing the property you are interested in displaying such as {{tab.somePropertyName}}.
Using Aurelia, I want to fill an <div> with contents of viewmodel property (lets call it htmlText) which contains html text, and I was using
<div>
${htmlText}
</div>
However, this encodes html so, instead of i.e. having paragraph or link, all tags are escaped so html can be seen as source.
Is there out of the box binder to do this?
You can accomplish this using the innerhtml binding like so:
<div innerhtml.bind="htmlText"></div>
I'm trying to change the style of a blog post (for instance change the title color), based on the labels associated to the post.
I'm a bit new to the templating, so I though I would be going to add a class with the label in the title <h3> element, and then add my CSS rules.
So I found this which would generate a proper list of labels separated by a space:
<b:loop values='data:post.labels' var='label'><data:label.name/> </b:loop>
However, it seems the validator does not let me add this inside the class attribute as follow:
<h3 class='post-title entry-title <b:loop values="data:post.labels" var="label"><data:label.name/> </b:loop>'>
From there, I found half the solution. Apparently, I should use expr:class instead of class as follow:
<h3 expr:class='"post-title entry-title " + data:list_of_labels'>
So now:
- How can I build this variable data:list_of_labels? (basically how to set a variable)
- Is there a full description of the template syntax somewhere?
- Is there another way to go around this?
Thanks,
JB
This should do it. Using XML entities allows you bypass the XML validation and move the Blogger functions to where you need them. Longer explanation here: http://www.karlhorky.com/2012/06/add-blogger-labels-to-post-as-css.html
<div class="post<b:if cond="data:post.labels"><b:loop values="data:post.labels" var="label"> <data:label.name></data:label.name></b:loop></b:if>">
<data:post.body>
</div>
There is no way to set variables in the blogger data xml, however you can set variables using javascript.
There are many pages on the blogger data xml. Google is your friend. For example this one.
You are on the right track: do a loop, use javascript to check for the combinations you want, change the style properties or load a css file dynamically.
Using Spring 2.5 tag library,
I have an Integer value in a command form that's rendered on my page using <form:input path="budget" htmlEscape="true" />
When the value is > 999, it renders the number as value="x,xxx" on the page. My validation isn't expecting the comma and rejects the value.
Is there a fix for the rendering, or do I need to fix the validation and parsing?
As usual, I was just being blind, and discovered that there was a custom property editor bound to the command form in the controller. It was causing the input field to render with commas.
That would have been fine, if there also wasn't a JavaScript validation that rejected the field for having commas in it.