I am Using Crispy form in Django, But now I like to change the text and style in the form of how to do it?
Suppose I like to change the camp Name to the Only Name, the Text is taken from Django Model, But I like to change here and also I want the text should be on left of text field not on top, How to do it
For horizontal forms see the docs here, same rules apply for bootstrap 4.
https://django-crispy-forms.readthedocs.io/en/latest/crispy_tag_forms.html?highlight=Inline#bootstrap3-horizontal-forms
To change the fields labels see the django docs
class AuthorForm(ModelForm):
class Meta:
model = Author
fields = ('name', 'title', 'birth_date')
labels = {
'name': 'Writer',
}
https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#overriding-the-default-fields
Related
#foreach ($tags as $tag)
#{{$tag->name}}
#endforeach
I'm trying to show some hashtags with the correct name and color being pulled from a database. The info is all there, but for some reason, the colors do not work when being set like this. They show up as classes when inspecting, but have no effect.
#roleplay
If I remove the {{}}'s and enter the color manually, as it is in the database, the colors show up correctly. Also worth a mention that sometimes the color would show up for one a tag, but not for the others.
Tailwind doesn’t handle dynamic class names well and even says in its documentation to not construct class names dynamically.
What you could do is either store the entire tag class in your database (text-blue-500), or store just the colour and construct the class name in your controller then provide that to your view as part of the tag data.
From the tailwind documentation, dynamically generated class names must be explicitly included in their safelist.
tailwind.config.js
module.exports = {
content: [
'./pages/**/*.{html,js}',
'./components/**/*.{html,js}',
],
safelist: [
'text-2xl',
'text-3xl',
{
pattern: /bg-(red|green|blue)-(100|200|300)/,
},
],
// ...
}
The above config will allow for exceptions of specific tags - like text-2xl or those following a regex pattern.
I want to display custom data which is coming from an API which will have data in 4 lines in Person Mgt,
I don't want to use default data from personquery, so how can I pass list of people's data in the Person Mgt also by default it shows data in just three lines but I want to display 4 details of an individual in 4 different lines in SPFX.
I've provided sample implementation of the code,
public render(): React.ReactElement<IMgtComponentsProps> {
return (
<Person
personQuery="me"
//personDetails={personDetails}
view={ViewType.threelines}
fetchImage={true}
avatarType={avatarType.photo}
personCardInteraction={PersonCardInteraction.hover} />
);
}
I'll be having similar type of custom data as shown below so I want to show these details as per user.
const personDetails = {
displayName: 'Bill Gates',
mail: 'nikola#contoso.com',
role:'Developer',
community:'Software Enginnering'
}
I tried passing this object inside personDetails property of Person but it's not working.
Currently a fourth line of data is only support via a custom rendering template
Here's an example of that using the raw web component as opposed to the React Wrapper.
<mgt-person class="my-person" person-query="me">
<template>
<div>
Hello, my name is: {{person.displayName}} <br>
{{person.role}} <br>
{{person.community}} <br>
{{person.mail}}
</div>
</template>
<template data-type="loading">
Loading
</template>
</mgt-person>
const person = document.querySelector('.my-person');
person.personDetails = {
displayName: 'Bill Gates',
mail: 'nikola#contoso.com',
role: 'Developer',
community: 'Software Enginnering'
};
With the existing three line view you can map each of the lines to your custom properties, assuming you have the above custom data being passed correctly you can have the component render the chosen properties on each line.
<mgt-person
class="my-person"
view="threeLines"
line2-property="role"
line2-property="community"
person-card="hover"
fetch-image>
</mgt-person>
The good news for the four-line case is that we are adding that to the library as part of our v3 release which is currently being worked on.
Is it possible to add css classes to auto-generated outer div for block element ?
I have a simple Block with a ViewModel and a Controller and I need modify this autogenerated outer div, or optionally remove it?
I looked at other answers to this question where it was recommended ie.
#Html.PropertyFor(model => model.CurrentBlock.ClientLogos, new
{
CustomTag = "ul",
CssClass = "list",
ChildrenCustomTagName = "li",
ChildrenCssClass = "list_item"
})
Problem is when I use this syntax, model has no CurrentBlock property ???
My model is bound to ViewModel, I'm not sure if it affects this. I am very new to Optimizely.
You can use custom tag and css class. In your example CurrentBlock is probably part of the viewModel, you can directly use model.ClientLogs. Alternativly if you want more control you can use editing attributes.
<h1 #Html.EditAttributes(x => x.Heading)>
/* Render the Heading property, unless it it empty, then use PageName as fallback */
#Model.Heading ?? #Model.PageName
</h1>
You can find more information about editing attributes here: https://docs.developers.optimizely.com/content-cloud/v11.0.0-content-cloud/docs/adding-editing-attributes-using-property-web-control
I have a repeater that looks like
<ion-item ng-repeat="obj in data">
{{obj.value}}
</ion-item>
which displays an item list of the numbers 1 through 10. When an odd number shows up I want that particular item to be hidden. Is this something I can do within the view it's self? Regardless what's a good way to do this?
You have to control your data set in your controller:
$scope.ProId = "";
$scope.HideOdd = function (){
-- create a function to hide DATA
}
and on your ion tag ad ng-hide="HideOdd"
I am new to Magento. I have made a custom module named "Custom_Press" using module creator and I customized it little bit. Its working fine.
Following are the fields in the form of my module.
Press Title
Press Image
Press Date
Press Thumbnail
Status
I want to show all of its data in a grid serializer in a custom product tab. So that any press can be selected from the grid serializer against any product like the default magento functionality of upsell and cross-sells product's grid serializer.
you need to add new tab to Tabs block 'Namespace/Module/Block/Adminhtml/Form/Edit/Tabs.php':
$product_content = $this->getLayout()->createBlock('module/adminhtml_form_edit_tab_product', 'adminform_products.grid')->toHtml();
$serialize_block = $this->getLayout()->createBlock('adminhtml/widget_grid_serializer');
$serialize_block->initSerializerBlock('adminform_products.grid', 'getSelectedProducts', 'products', 'selected_products');
$serialize_block->addColumnInputName('position');
$product_content .= $serialize_block->toHtml();
$this->addTab('associated_products', array(
'label' => Mage::helper('module')->__('Products'),
'title' => Mage::helper('module')->__('Products'),
'content' => $product_content
));
The serializer is most important feature which allow you to define fields which will be editable in the grid, and define a name parameter which you should see in Save action of the form.
For more details please have a look at -
http://turnkeye.com/blog/magento-admin-form/