placeholder in <aui:select> for dropdown liferay - dropdown

How can I have a placeholder value in a dropdown ? Something a user will be shown in a dropdown but he will not be able to 'Select' that option.
For example: I'll have a placeholder as 'Please Select an Item' as a selected text in dropdown(placeholder) but user will not be able to select 'Please Select an Item' as an item from dropdown list.
Currently I do have to use things as shown in below code
<aui:select label="" id="admin" name="optionsSelect">
<aui:option value="1">Please Select an Item</aui:option>
<aui:option value="2">Item1</aui:option>
<aui:option value="3">Item2</aui:option>
<aui:option value="4">Item3</aui:option>
<aui:option value="5">Item4</aui:option>
</aui:select>

the only option to have a select with something like a placeholder is to add as you did a first option to the select, but adding also the options "selected" and "disabled" and its value empty, that is:
<aui:select label="" id="admin" name="optionsSelect">
<aui:option value="" selected="true" disabled= "true">Please Select an Item</aui:option>
<aui:option value="2">Item1</aui:option>
<aui:option value="3">Item2</aui:option>
<aui:option value="4">Item3</aui:option>
<aui:option value="5">Item4</aui:option>
</aui:select>
Hope that help.

Related

odoo 8 make button invisible from compute result

This is my .py
#api.depends('product_id')
def get_sales_divisi(self):
for line in self:
if line.product_id.divisi_update:
line.sales_divisi_id = line.product_id.divisi_update.id
elif line.product_id.divisi_ids:
line.sales_divisi_id = line.product_id.divisi_ids.ids[0]
this is my .xml
<button name="action_approve" string="Approve Checker" type="object" attrs="{'invisible':['|',('sales_divisi_id', '=', '2'),('sales_divisi_id', 'in', ('VET'))]}" groups="ts_addons_tbk.group_tbk_checker" />
I'm tying to make the button invisible when the sales_divisi_id is Vet but it doesn't work. Any advice please? Thank you
Assuming sales_divisi_id is a relation, in operator will query by id or name field.
Furthermore, in order to use fields in queries inside your views, you need to define them first.
For example:
<field name="sales_divisi_id" invisible="1" />
<button name="action_approve" attrs="{'invisible':[('sales_divisi_id', 'in', [1,2])]}" groups="ts_addons_tbk.group_tbk_checker" />
action_approve button will show only if sales_divisi_id is related to a record having id 1 or 2.

Possible to have multiple crowd-classifier elements in mturk?

Is it possible to have two crowd-classifier elements? I tried the follow, for example, but it just duplicates the form and results in two submissions buttons. How do I make it so that there is only one submission button and one set of instructions/shortcuts?
<crowd-form>
<crowd-classifier
name="category"
categories="['Optimism', 'Neutral', 'Other']"
header="Select the relevant categories"
>
<classification-target> ${text} </classification-target>
</crowd-classifier>
<crowd-classifier-multi-select
name="category"
categories="['Admiration', 'Gratitude', 'Curiousity', 'Optimism', 'Neutral', 'Other']"
header="Select the relevant categories"
exclusion-category="{ text: 'None of the above' }"
>
<classification-target> ${text} </classification-target>
</crowd-classifier-multi-select>
</crowd-form>

"---please make a choise---" prestashop form

i would like to make default "---please make a choice--'. Actually in checkout adress form state is compilate like italia. I put a screenenter image description here
You need to find block responsible for showing province field and add something like this right above foreach loop:
<option value disabled selected>{l s='-- please choose --' d='Shop.Forms.Labels'}</option>
Example based on "Select a country" located in prestashop\themes\classic\templates_partials\form-fields.tpl:
{block name='form_field_item_country'}
<select
class="form-control form-control-select js-country"
name="{$field.name}"
{if $field.required}required{/if}
>
<option value disabled selected>{l s='-- please choose --' d='Shop.Forms.Labels'}</option>
{foreach from=$field.availableValues item="label" key="value"}
<option value="{$value}" {if $value eq $field.value} selected {/if}>{$label}</option>
{/foreach}
</select>
{/block}

vee-validate regex does not work as expected

I am working with VUE and VEE-VALIDATE and want to check if an input is an valid decimal with comma as seperator.
My input with regex look like this:
<input type="text" v-model="myDecimal" v-validate:myDecimal="{ regex: /^(\d+|\d+,\d+)$/ }" :class="{'error': errors.has('mydecimal') }" ref="mydecimal" name="mydecimal" />
<span v-show="errors.first('mydecimal')" :class="{'field-validation-error': errors.has('mydecimal') }">NOT CORRECT DECIMAL!</span>
This works quite good for "1", "1,2", "0,4", "12,28761". Perfect!
Errors are displayed correctly for ",0", "foo", "1e". Perfect!
But if I type in the following I get NO error, but I would expect one: "1,1,1" or "1,1foo".
Any ideas what i am doing wrong?? Thanks!
Before (not working example):
<input v-model="myDecimal" v-validate:myDecimal="{ regex:/^([0-9]+|[0-9]+,[0-9]{0,2}?)$/ }" />
After (working example):
<input v-model="myDecimal" v-validate="{ regex:/^([0-9]+|[0-9]+,[0-9]{0,2}?)$/ }" />

How do I conditionally add an id attribute in TAL (PHPTAL)?

I'm creating a form elements template file in PHPTAL. I would like to be able to OPTIONALLY pass in an id attribute for a field...
So far the code looks like this:
<xml>
<tal:block metal:define-macro="text">
<label tal:condition="php: !isset(hideLabel) || isset(hideLabel) && !hideLabel">${field/label}</label>
<input name="${name}" type="text" value="${field/value}" />
<p tal:condition="exists:field/error">${field/error}</p>
</tal:block>
</xml>
This works as advertised. What I'd like to add is something, like
<input name="${name}" tal:attributes="id exists: id $id | $name" value="${field/value}" />
to allow me to optionally pass in an id from the METAL call...
Should I be doing it differently? I've tried using PHP: isset(id) ? $id : NULL and variations thereof, but just end up with an id="0" in the resultant HTML.
Any ideas?
In case anyone else needs it, one working answer is:
<xml>
<tal:block metal:define-macro="text">
<label tal:condition="not: exists:hideLabel">${field/label}</label>
<input name="${name}" tal:attributes="id id | nothing" type="text" value="${field/value}" />
<p tal:condition="exists:field/error">${field/error}</p>
</tal:block>
</xml>
Where passed in variables are id, name, an array named field, and hideLabel .
Note, that I've also managed to simplify the label test to something which I believe is more idiomatically TAL.
Set VAR at a DIV containing the soon to be used element:
div class="" tal:define="VAR context.property"
div class="" tal:attributes="class python:'grid_8 omega' if VAR else 'grid_8 alpha'"
in PHP:
<div id="contentCenter" tal:attributes="id
php:isset(variable)&&isset(variable.property)?'IDVALUE':NULL">