Classes on optgroup in yii 1 - yii

Is it possible to create a drop-down in yii 1 where optgroups have classes?
I want to use $form->dropDownList()
eg:
<select>
<optgroup label="Swedish Cars" class="swedish">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</optgroup>
<optgroup label="German Cars" class="german">
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>

I just looked at the documentation (http://www.yiiframework.com/doc/api/1.1/CHtml#activeDropDownList-detail) and source code and there is nothing implemented to set the class, or any other attribute for the <optgroup> tag (see here: https://github.com/yiisoft/yii/blob/1.1.19/framework/web/helpers/CHtml.php#L2547).
The only way I can see for you to achieve this is to implement your own class, extending CHtml, and override the function listOptions() with your own implementation. That could then handle any additional options for optgroup classes as you wish.
Note that with this approach you then can't use $form->dropDownList() but would have to use YourNewClass::activeDropDownList() instead.
Hope this helps...

Related

Vue select tag on change not firing when selecting the same option

I have a select tag that should trigger function when an option is selected.
<select id="selector" class="form-control" #change="executeAction" v-model="selectedAction">
<option value="" selected disabled>Select action</option>
<option value="view">View Details</option>
<option value="edit">Edit</option>
<option value="delete">Delete</option>
</select>
methods: {
executeAction() {
console.log('action is se', this.selectedAction);
},
}
Now, what I expected was:
When selecting the same option for the second time (For example: View Details), it should log the selected option.
What I got:
It's not firing at all, I need to select other option so that I can reselect the View Details again.
What I tried:
Using watch, and the result was the same.
Using #input instead of #change, still result was same.
Usin v-on: instead of #, still no luck.
Is this a bug? or wrong implementation?
Anyways, would be great to have an answer to this.

How do I locate a select option element in Selenium WebDriver?

I have the following html code below: How do I locate and click any of the options e.g 'verve'?
<div id="cardsSelectList">
<select id="cardtype" class="selinput" tabindex="1" onchange="webpay.ProcessCardTypeSelection($(this).val())" name="cardtype">
<option value="-1">- Select your card type -</option>
<option value="1|1|1|Card Number|0|Card PIN|1|0|||0|0">Verve\u2122</option>
<option value="1|1|1|Card Number|0|Card PIN|1|0|||0|0">MasterCard\u2122 Naira Debit</option>
<option value="1|0|1|Card Number|0|Card PIN|0|0|||0|0">Visa</option>
</select>
Use Select class
#FindBy(id="cardtype")
private WebElement selectElement;
Select select = new Select(selectElement);
select.selectByValue("1|1|1|Card Number|0|Card PIN|1|0|||0|0");
You also have option to select byt text, index etc. refer to this
written in java and refer to java. But the api is fairly similar for any other bindings

How to select the Dropdown option based on class selection using webdriver

When the user expands the menu and chooses and option, how can I get the selected option with Selenium?
<select class="brand-select select-glossy user-success" name="">
<option value="All Makes">All Makes</option>
<option value="Ford">Ford</option>
<option value="Lincoln">Lincoln</option>
<option value="Mercury">Mercury</option>
</select>
Find the select element and make a Select object our of it (need to import org.openqa.selenium.support.ui.Select)
Use the API therein to get the first selected option:
WebElement selectedOption = new Select(driver.findElement(By.className("brand-select"))).getFirstSelectedOption();

PrestaShop: Get value of select menu

Is there any possible way to get a selected value in Prestashop without javascript? I tryed with Tools::getValue() but it doesn't work...
<select name="selectPosition" id="selectPosition">
<option value="0">---</option>
<option value="1">'.$this->l('Left').'</option>
<option value="2">'.$this->l('Right').'</option>
</select>
Best regards,
George!
Tools::getValue checks is value is in POST or in GET, just pass the value you want to check ad param
if (Tools::getValue('selectPosition') {
//make something
}

How to select a combobox in geb with groovy

This is what I have currently with Geb. I want to be able to retrieve and set the value of a combobox (or drop down) in a page. I'm not quite sure how to do it, and the Book of Geb does not seem to cover this. This is the HTML element that I'm trying to work with.
<select style="height: 22px; width: 370px;" id="ddlContactTypes" name="ddlContactTypes">
<option value="-1">--Please Select--</option>
<option value="18">Customer Hauler</option>
<option value="19">Customer General</option>
<option value="20">Rolloff</option>
<option value="21">Supplier</option>
<option value="22">Leads</option>
<option value="23">Competition</option>
<option value="24">Employees</option>
<option value="25">Customer Car</option>
<option value="26">Secondary Metals Recycler</option>
<option value="27">Mills</option>
<option value="28">Brokerage Customers</option>
<option value="29">Type Jon</option>
</select>
This is what I've go so far. This currently will click the element, but I don't know how to actually select one. Any ideas?
static content = {
title {$("title")}
contactType { $("#ddlContactTypes") }
}
def addUser(){
contactType.click()
}
You can select an option by setting the value of the geb object :
contactType.value('20')
Above example will set the value to '20', making the list show 'Rolloff' as selected.
U can see this
HTML
Alt folk
Chiptunes
Electroclash
G-Funk
Hair metal
GOOVY
$("form").artist = "1" // first option selected by its value attribute
$("form").artist = 2 // second option selected by its value attribute
$("form").artist = "Ima Robot" // first option selected by its text
http://www.gebish.org/manual/0.9.2/navigator.html
Manual descibes it in section Setting Values