I'm using contact form 7 and here is the actual contact form 7 code to display the select drop down
<div class="select-wpr">[select* program id:program first_as_label required "Choose your program of interest"]</div></div>
<div class="full-width">
<div class="select-wpr">[select* campus id:campus first_as_label "Choose campus"]</div>
</div>
Where can I go and modify the actual select drop down options? I want to add <optgroup> to the select options but can't find where to go and modify that. Where is that located in wordpress?
To my best knowledge there is no possibility to use optgroups with contact form 7. You may send a feature request to the developers, but i doubt that they will implement it as it is not needed too often.
The first possible solution is to use a more flexible Plugin than Contact Form 7 for this purpose or you code this particular form yourself.
The second possibilitiy is to use a JavaScript approach which modifies the select after it is loaded:
$(function(){
var foundin = $('#some_select option:contains("optgroup-")');
$.each(foundin, function(value){
var updated = $(this).val().replace('optgroup-','');
$(this).nextUntil('option:contains("endoptgroup")').wrapAll('<optgroup label="'+updated+'"></optgroup>');
});
$('#some_select option:contains("optgroup-")').remove();
$('#some_select option:contains("endoptgroup")').remove();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<select id="some_select">
<option>optgroup-First Group</option>
<option>Some Option</option>
<option>Some Option</option>
<option>Some Option</option>
<option>Some Option</option>
<option>Some Option</option>
<option>endoptgroup</option>
<option>optgroup-Second Group</option>
<option>Some Option</option>
<option>Some Option</option>
<option>Some Option</option>
<option>Some Option</option>
<option>Some Option</option>
<option>endoptgroup</option>
</select>
(found on CodePen: https://codepen.io/adrian-ortega/pen/Ivzjh)
You can't use optgroup elements in Contact Form 7 drop downs as it doesn't seem to support it in the shortcode syntax unfortunately. The documentation on the official site outlines the possible options.
id:(id)
class:(class)
default:(num)
default:1_2_3
multiple
include_blank
first_as_label
data:(name)
Related
Hi Hope everyone is doing fine unlike me as I am stuck in this problem since quite a while and seek your answer on this. I am using angular version 9
I have a an HTML like:
<div class="view-product d-flex align-items-center">
<p>View</p>
<select (change)="check()">
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
</select>
</div>
and in Component.ts I have code
check(){
console.log(1)
}
when my page gets loaded it forms 2 select (one is hidden and other with the styles applied to it).
So when I choose any option "check" doesnot gets called. If I inspect the 'select' and remove its 'display:none' in dev tools and then select an option 'check' gets triggered.
So point is after the css or styles gets applied to it change doesnot work. Please Help me out !!
This is happening because of a js plugin file(niceselect plugin) which is beautifying the select control. If I exclude that js file the control becomes NORMAL AND FUNCTIONAL
I am including that file in my HTML Like
<html>
<body>
<app-root></app-root>
</body>
<!-- Plugins js -->
<script src="assets/js/plugins.js"></script>
</html>
I've searched a bit but the found solutions here on SO seems not working for me. I have a select input field and I want to assign it a placeholder. I'm using bootstrap 4 and to manage the front-end.
As I understand from the documentation I need to assign the selected hidden or selected disabled to the <option> tag I want to use as placeholder. I've tried but didn't worked.I don't know if this is because I'm using vue.js, is there a fix?
<label>Filter List</label>
<select
class="form-control"
v-model="listFilter"
v-on:change="filterList()"
>
<option value="" selected disabled class="text-hide">Select filter</option>
<option value="a">All</option>
<option value="f">Fe</option>
<option value="m">Mas</option>
<option value="s">Tru</option>
<option value="c">Cou</option>
</select>
I have the following code:
<form:select path="roles" items="${roleList}" itemLabel="roleType" itemValue="id" />
It generates html as below:
<select id="roles" name="roles" multiple="multiple">
<option value="1">ROLE_ADMIN</option>
<option value="2">ROLE_HQ</option>
<option value="3">ROLE_MASTER</option>
<option value="4">ROLE_STATE</option>
<option value="5">ROLE_CENTRE</option>
</select>
Also I do not use the multiple optional attribute. Any idea why does the generated HTML contain "multiple="multiple" ?
Just a guess, but since you mapped it on roles, and since roles is probably a collection, it makes sense to make the select box multiple. If it was not multiple, you would only be able to store a single item in the collection. And the tag would not be able to display the selected roles.
EDIT: after reading the source code of the tag, it appears my guess was right. See the forceMultiple() method in SelectTag.
I found a problem with ubercart for Drupal and I am trying to find a workaround. I would like to display the options of an attribute as radio buttons by default instead of a select box. The problem with ubercart is that there is a way to set the default by setting it at admin/store/attributes/ but it is always overriden at the product level. So the content uploader has to select radio buttons for every product.
The work around I would like to implement is with hook_form_alter or similar. But I am struggling at finding the right function to override. If it can be of any help, here is the source code of the select box:
<div class="attribute attribute-1 odd">
<div id="edit-attributes-1-wrapper" class="form-item">
<label for="edit-attributes-1">
Color:
<span class="form-required" title="This field is required.">*</span>
</label>
<select id="edit-attributes-1" class="form-select required" name="attributes[1]">
<option selected="selected" value="">Please select</option>
<option value="7">Black | 000000</option>
<option value="6">Blue | 5E79A4</option>
<option value="5">Red | C33438</option>
</select>
</div>
</div>
This was fixed in Drupal 7/Ubercart 3. Have you tried deifining product classes and the defaults for that class. Your default options may stick when adding a product under a class.
How to design a dropdown on XSLT? I need a dropdown with four values
option 1
option 2
option 3
option 4
I have the following on the XSLT
<div>
<select>
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
<option value="option4">Option 4</option>
</select>
</div>
I wanted to pass the selected value from the dropdown to the asp.net
XSLT has nothing to do with "designing a dropdown". It is an XML-based language to transform an input XML tree into some other form of output. XSLT has no concept of a "dropdown", that would be in whatever web or UI system you're using.
First design the output, in other words, decide specifically what HTML you want to produce.
Then determine the input XML and figure out what parts of it need to be reflected in the output dropdown.
If you can show us those two things, we can help you figure out what sort of XSLT to use.
FYI there is an example here of an XSLT template for generating an OPTION/SELECT. You could try that and let us know if you need help figuring out how to use it.