Symfony search form - symfony1

I use symfony 1.4.12 with Zend Lucene. And I make custom search, I have field like category, country...I create module and I have MysearchSucess.php and there I write hardcode, like :
<select name="ads_country" id="ads_country">
<option value="AF">Afghanistan</option>
<option value="AX">Ă…land Islands</option>
<option value="AL">Albania</option>
</select>
etc... But there are in symfony nice widget like sfWidgetFormI18nChoiceCountry;
Or for examle, if user add category, I will need to add new category in code manualy... Is it possible to use widgets in my case? how to organize it right without hardcode?
Thank you!

Ok, I read this and all ok!

Related

MVC razor DisplayFor a list

I have a view, with a list that i have populated. I want to have a DisplayFor that will change and show what is selected in the drop down list.
This is my view so far. I have tried googling the problem, and after a few hours of reading through pages i cant find anything specific to what i am trying.
<select id="Test1">
<option value="test">Role1</option>
<option value="test">Role2</option>
<option value="test">Role3</option>
<option value="test">Role4</option>
</select>
#Html.DisplayFor(Test1)
But of course this will just not work. And i really dont know what to try now.
I tried using Test1.selected, and i also tried having Test1 as a model then pass a list through, but it would require a page to be refreshed.

How to do Multiple select in thymeleaf?

I'm using thymeleaf for my UI part. I have a query.I have created a student and linked with different department. now while showing the student detail, i have to show the all the department and as well as mapped department in the select box which allows the multiple selection of the department. i have no idea how to do that can some one help me to fix this issue.
This snippet should do the work:
<select id="multiSelectElementsSelected"
name="multiSelectElementsSelected"
multiple="multiple"
th:field="*{departments}">
<option th:each="department,row : ${collectionOfDepartments.values()}"
th:value="${department.value}"
th:text="${department.label}"></option>
</select>

I want to make multiple selection using a href

Hi I want to make multiple selection a href.
Please help me to how to do it.
Thanks for your help.
If you ask for the below mentioned answer:
<select onchange="location.href=this.value;">
<option value="http://some_url/1.jpg">1.jpg</option>
<option value="http://otherurl/2.jpg">2.jpg</option>
</select>

Using custom data attribute in Struts 2 s:select

I'm trying to use custom data attributes of HTML in Struts2 tags
here is my sample code
<s:select list="myList" listKey="myListVal" listValue="myListDesc" data-inputs="myListInput" ></s:select>
i was expecting something like this for example
<select >
<option value="myListVal1" data-inputs="myListInput1">myListDesc1</option>
<option value="myListVal2" data-inputs="myListInput2">myListDesc2</option>
<option value="myListVal3" data-inputs="myListInput3">myListDesc3</option>
</select>
instead I'm getting this
<select data-inputs="myListInput" >
<option value="myListVal1" >myListDesc1</option>
<option value="myListVal2" >myListDesc2</option>
<option value="myListVal3" >myListDesc3</option>
</select>
Is it possible to describe data-attribute in struts select tags for Options inside it.
Override the <s:select> tag template. Or just use HTML tags with <s:iterator>
<select name="list">
<s:iterator value="myList" status="stat">
<option value="<s:property value="myListVal"/>" data-inputs="myListInput<s:property value="#stat.index"/>"><s:property value="myListDesc"/></option>
</s:iterator>
</select>
You can't inject custom attributes into a Struts2 UI Tag directly.
According to Dave Newton's comment, you can with Struts2 >= 2.1.x
But still it's not possible to apply them to the option elements instead of the select, so I'll leave the answer in case you need to extend the original select tag to define a custom behaviour (like apply certain attributes to the options).
You can extend the <s:select> Struts2 tag to allow it to manage new kind of attributes...: http://bodez.wordpress.com/2009/03/13/customising-struts2-jsp-tags/
,
or create your own tag directly, but in your case would be overkill: http://joshuajava.wordpress.com/2008/12/27/creating-custom-components-with-struts-2/).
Last but not least, you could even add your custom attributes once the page is rendered, using something like jQuery (demo: http://jsfiddle.net/CLNDs/ ); they will be accessible, but not visible in source.

Freemarker hash for Struts2 #s.select tag's list property

I'm using Freemarker as the templating engine for a Struts 2 application and having some problems trying to pass a Freemarker hash to the #s.select tag's list value.
Currently I'm trying something like this in my template:
<#s.select name="myDropdown" list={"1":"Foo", "2":"Bar", 3:"Baz"} />
The resulting HTML that's rendered is this:
<select name="myDropdown" id="myDropdown">
<option value="freemarker.ext.beans.HashAdapter$1$1$1#2c9bebb">freemarker.ext.beans.HashAdapter$1$1$1#2c9bebb</option>
<option value="freemarker.ext.beans.HashAdapter$1$1$1#16ca4a">freemarker.ext.beans.HashAdapter$1$1$1#16ca4a</option>
<option value="freemarker.ext.beans.HashAdapter$1$1$1#173ee8">freemarker.ext.beans.HashAdapter$1$1$1#173ee8</option>
</select>
Based on the documentation it seems like this should work, but really the only examples are of using Freemarker lists. Hashes are only mentioned as another option, but I haven't been able to find any code examples that use them.
Ultimately my question is, what Freemarker syntax should I use with the Struts 2 select tag in order to render the following HTML?
<select name="myDropdown" id="myDropdown">
<option value="1">Foo</option>
<option value="2">Bar</option>
<option value="3">Baz</option>
</select>
Using the listKey and listValue properties of the select tag seems to do the trick.
The working code is now:
<#s.select name="myDropdown" list={"1":"Foo", "2":"Bar", 3:"Baz"} listKey="key" listValue="value" />
Seems like that should be taken care of automatically by the tag, but I was not able to get it to work without explicitly setting those two additional properties.

Resources