Magento 2 dynamic UI form - magento

Based on the type(value) I want to render the different fields in the same form. And also I want to make some field as readonly or disabled based on the value.
Refer the below screenshot for more understanding.
This form is based on type 1
This form is based on type 2
Type is a hidden field
This I can achieve by Widget Generic form but I want to implement in UI form, Because in my form I am also using magento default address form(UI).
Please help me if anybody knows.
Thanks in Advance!!!

Related

How can i create a view with content type but not basic page and article

I have created three content types
1)A form
2)B form
3)C form
In total there are now 5 content types including
Basic page and article
Now i have created a view but all content types are allowed including page and article. I want to create a view using these three:
A form B form C form
Is there any way? I have checked but while creating view there is no multiple select for content type allowed?
Now
select
All
page
artcle
A form
B form
C form
Please help me to solve this issue. Any help would be appreciated, Thank in advance
Edit your view and go to filter criteria.
Here you can add a filter for content types.
Example from the /admin/content view. Except you probably don't want to expose your filter to visitors in your case:

Django add fields to form dynamically based on number of values in model choice field

Objective:
From a Django Form, modelchoice field i am making the widget display multiple checkboxes. But for each checkbox I would like to display exactly one textbox and then submit. I need to know if the checkbox is not selected, it's id still and the possible textbox value. How do I acheive this, if it is Ajax. please elaborate. as I am fairly new to django and haven't worked much with ajax.
So you have to possible approaches here,
Simpler(but a very tardy approach):
Submit the form after user's checkbox input, process the input in views.py and accordingly serve the other part of the form on a different template. This will lead you to reloading the page and changing URL's for the same form. This approach is fine if you are doing it only to learn Django at first.
The better approach. You can use on page JavaScript/JQuery to determine whether the checkbox is ticked or no and the accordingly show the checkbox. You can do something like
if(document.getElementById('yourCheckBoxID').checked)
{
$("#FormFieldID").show();
}
else
{
$("#FormFieldID").hide();
}
If you are doing the latter, do remember to NOT set the input field as "required", as it may throw up errors when not showing the text field. Use some sort of JS form validation if you have to.
Hope this helps!

Django Autocomplete-Light allow any text input fields

I have Django Autocomplete-light running with Crispy Forms, but I need to allow users to enter any text into the form. At the moment the user can either select one of the options from the autocomplete dropdown, or nothing.
Note that I am using the Select2ListView from Autocomplete-light
Does anyone know how I can easily modify Autocomplete-light, or Crispy Forms to allow any text to be entered?
Thanks
Stephen
Your field is linked to a foreignkey, so you can create an inline form that points to your related model in your view.

Sitecore page editor dropdown

I would kindly ask for your help :) From couple of days I am trying to achieve "linked" custom field in content editor and dropdown in page editor.
Basically I want to have dropdown in page editor and content editor which are responsible for a same thing.
In my c# code i have enums which represent directions. I created custom field which accepts assembly and class with overridden onload method and successfully populate dropdown values in the content editor. So far so good but i have no idea how to create dropdown which will represent the same functionality inside page editor.
So please give me any ideas...
Judging from your reply to my comment you need to think of the following: How is my field value being rendered onto a page?
If you are always using 1 control to do this then you just need to ensure that this control has 2 different rendering modes depending on the Context.PageMode
But as I understand it you want this dropdown to also appear when someone renders your custom field using a <sc:FieldRenderer>. In this case you'll need to look into the RenderField pipeline of Sitecore. There you find a processor called RenderWebEditing. Possibly through some manipulation here you can get your dropdown appear as you wish.

Which dojo widget should be used for DropDown

I wish to create dynamic dropdown, meaning the value of the second dropdown changes with the change in selection on the first. I was looking through the Dojo docs and it seems there are 3 different widgets that I can use,
dijit/form/ComboBox
dojox/form/DropDownSelect
dijit.form.Select
Now I am confused as to which one should i use for creating Dynamic DropDowns?
You can choose anyone depending upon what extra features you want. While dijit.form.Select is your normal HTML select, combobox and filteringselect offer more features.
Follow http://kennethfranqueiro.com/2010/06/combobox-vs-filteringselect/ for a comparison between the two. You can also play with them to know how they work.
I had used FilteringSelect in my app for the same behavior as need.
Differences between dojo dropdown :
Select It is simple combobox like select in HTML with no validation
and not provide any search facility inside select options.
ComboBox It is pure form of combobox and name as ComboBox again it
will not provide any default validation but it provide search
facility within its options.
FilteringSelect It is an advance form of select have default
facility of validation and search facility. And it also has property
to take value as input tag take value in HTML.
In dojo you can also try custom validation which is provided inside dojox library. I hope it will help you.

Resources