I want to use radio buttons on document property page.
To add checkbox i used below code.
<control template="/org/alfresco/components/form/controls/checkbox.ftl">
In Above case checkbox.ftl is provided by alfresco. But there is no any RadioButton.ftl available.
So how can i use radio button on property page?
If any one have achieved this, then please help me.
Thanks in advance.
You can develop your own control, based on the Form Control Alfresco documentation.
On this specific page, you have more information about the howto.
Finally, I would suggest you to take inspiration from the original checkbox.ftl to make your own :
<#assign isTrue=false>
<#if field.value??>
<#if field.value?is_boolean>
<#assign isTrue=field.value>
<#elseif field.value?is_string && field.value == "true">
<#assign isTrue=true>
</#if>
</#if>
<div class="form-field">
<#if form.mode == "view">
<div class="viewmode-field">
<span class="viewmode-label">${field.label?html}:</span>
<span class="viewmode-value"><#if isTrue>${msg("form.control.checkbox.yes")}<#else>${msg("form.control.checkbox.no")}</#if></span>
</div>
<#else>
<input id="${fieldHtmlId}" type="hidden" name="${field.name}" value="<#if isTrue>true<#else>false</#if>" />
<input class="formsCheckBox" id="${fieldHtmlId}-entry" type="checkbox" tabindex="0" name="-" <#if field.description??>title="${field.description}"</#if>
<#if isTrue> value="true" checked="checked"</#if>
<#if field.disabled && !(field.control.params.forceEditable?? && field.control.params.forceEditable == "true")>disabled="true"</#if>
<#if field.control.params.styleClass??>class="${field.control.params.styleClass}"</#if>
<#if field.control.params.style??>style="${field.control.params.style}"</#if>
onchange='javascript:YAHOO.util.Dom.get("${fieldHtmlId}").value=YAHOO.util.Dom.get("${fieldHtmlId}-entry").checked;' />
<label for="${fieldHtmlId}-entry" class="checkbox">${field.label?html}</label>
<#formLib.renderFieldHelp field=field />
</#if>
</div>
Related
I have a object "item" from SpringMVC model.
if "item" equals 1, I want to print:
<input .../>
else, I want to print:
<span.../>
How can I achieve that?
thx.
I would do that with a switch statement...
<th:block th:switch="${item}">
<input th:case="1" />
<span th:case="*" />
</div>
Or multiple if/unless
<input th:if="${item == 1}" />
<span th:unless="${item == 1}" />
You can put it straight into html with th:utext, but I don't think it's a very good idea (as you can't use th:statments in the generated html, and you can't validate as a document etc...).
<th:block th:utext="${item == 1 ? '<input .../>' : '<span.../>'}" />
I'm trying to style input type file using Laravel -> Form::file:
<div class="col-md-3">
{{ Form::file('images[]', ["class"=>"required","multiple"=>true]) }}
</div>
It should look like that:
I've searcched in web for some solutions and there are possibilities with js but in some of them it's commented that it's not always working in all browsers.
What should be the right way to do that?
you can solve this through "label" tag.
<label for="form-file">Upload a file</label>
<input type="file" name="file" id="form-file" class="hidden" />
Just hide the input with css or move it somewhere -9999px to the left, and style the label element to whatever you desire. When user will click on label it will show the upload popup.
I hope this help.
EDIT:
Here is example.
With "Form::file" you can just add label and add ID parametr to your function.
Here's you can attach your file in laravel
<div class="row p-t-20">
<input id="file-upload" type="file" name="banner_url" value="{{old('banner_url')}}" />
{!! $errors->first('banner_url', '
<p class="text-warning errorBag">:message</p>') !!}
<label for="file-upload" id="file-drag">
<div id="file-cont">
Select a file to upload
<br />OR
<br />Drag a file into this box
</div>
<br />
<br /><span id="file-upload-btn" class="btn btn-success">Add a file</span>
</label>
<progress id="file-progress" value="0">
<span>0</span>%
</progress>
<output for="file-upload" id="messages"></output>
this is the easy and the stylish way to input your file in laravel
please share anyone who needs this thanks
Is there a way to style the "popup" when a field is invalid in AngularJS?
I have no idea WHERE this thing is styled? We also have Bootstrap loaded, not sure if it's there. Can't right-click to "find element" either.
That's the browser validation kicking in. Disable it as follows:
<form novalidate></form>
Edit: Example of a form using novalidate with AngularJS's validation:
<form name="form" class="css-form" novalidate>
Name:
<input type="text" ng-model="user.name" name="uName" required /><br />
E-mail:
<input type="email" ng-model="user.email" name="uEmail" required/><br />
<div ng-show="form.uEmail.$dirty && form.uEmail.$invalid">Invalid:
<span ng-show="form.uEmail.$error.required">Tell us your email.</span>
<span ng-show="form.uEmail.$error.email">This is not a valid email.</span>
</div>
</form>
I believe it is no longer possible to style these popups:
Link
bool isChecked = false;
<input type="checkbox" name="x" checked="#isChecked" />
In MVC 4, The above code will be generate as
<input type="checkbox" name="x" />
But in MVC 3,Need to write like this:
bool isChecked = false;
#if(isChecked)
{
<input type="checkbox" name="x" checked="checked" />
}
else
{
<input type="checkbox" name="x" />
}
If we are Microsoft developers, Which assembly need to modify and how to modify it?
How to customize the upgrade code?
Plase help me,thanks!
To be honest I don't really understand the question after those code blocks, but I can say that you can use inline condition in your views in ASP.NET MVC3. Something like that for example:
bool isChecked = false;
<input type="checkbox" name="x" #(isChecked ? "checked=checked" : "") />
It's shorter and it will produce code like that:
<input type="checkbox" name="x">
And BTW, there is a helper method Html.CheckBox to create checkbox in your view and in second parameter you can indicate if you want it to be checked:
#{bool isChecked = false;}
#Html.CheckBox("x", isChecked)
And that will rendrer this:
<input id="x" type="checkbox" value="true" name="x">
<input type="hidden" value="false" name="x">
Try it on your own.
I'm writing a program in Java that submits a form using WebDriver. There is a method findElement that allows you to select elements using class name, css selector, id, link text, name, partial link text, tag name, or xpath.
Here's the button that I want to select:
<div class="editable" style = "width:82px;float:right;margin-right:10px;">
<a href="#" onclick="$('order_form').submit(); return false;" class="btn">
<img class="btn" src="/myhuds/images/rd_images/btn_place_order.gif" alt="Place Order" width="82" height="17" border="0">
</a>
</div>
I can't use class name because there are multiple buttons on the page. Any ideas on how I might go about using the findElement method to select this button?
Thanks!
Try using this. You can add some browser plugin to get XPath.
driver.findElement(By.xpath("Your XPath"));
You can add an id to the button (may be to all buttons in your page) and find as -
driver.findElement(By.id("Your ID"));
Use CSS selectors. You can find a short explanation here W3, and couple examples here :Examples.
Therefore, try to use driver.findElement(By.cssSelector(...));
For your specific case you can search based on img #alt attribute using XPath
driver.findElement(By.xpath("//img[#alt='Place Order']")).click();
Step 1:
With the available DOM Structure Generate CSS Selector for the "Place Order"
Image
css=a[onclick*='order_form'] > img[src*='btn_place_order.gif']
Then Perform Click on "Place Order" Image.
driver.findElement(By.cssSelector("a[onclick*='order_form'] > img[src*='btn_place_order.gif']")).click();
Following example should help:
Html File:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
<html>
<head>
<title>Login Page</title>
</head>
<body>
<h1 class="page-header">Login</h1>
<ul class="errors"></ul>
<div>
<form class="login-form" action="checkLogin.html" method="post">
<label for="username-field">Username1</label>
<input type="text" name="username" class="username-field" />
<br />
<label for="password-field">Password1</label>
<input type="password" name="password" class="password-field" />
<br />
<input type="submit" value="Submit" />
</form>
</div>
<div>
<form class="login-form" action="checkLogin.html" method="post">
<label for="username-field">Username2</label>
<input type="text" name="username" class="username-field" />
<br />
<label for="password-field">Password2</label>
<input type="password" name="password" class="password-field" />
<br />
<input type="submit" value="Submit" />
</form>
</div>
</body>
</html>
To locate the input field for Password1 :
WebElement passwordField1: driver.findElement(By.cssSelector("div:nth-child(3) .password-field"));
To locate the input field for Password2 :
WebElement passwordField2: driver.findElement(By.cssSelector("div:nth-child(4) .password-field"));
Learn more about nth-child() selectors here.