ExtJS - Dynamically add CheckBox to Form - forms

I'm trying to dynamically add new form components to a fieldset inside a form and I'm struggling with the checkbox component.
I'm getting the "TypeError: Ext.form.Checkbox is not a constructor" error on firebug. Here's my code:
...
Ext.getCmp('component1').add(new Ext.form.DisplayField({value: "aValue"}));
Ext.getCmp('component1').doLayout();
Ext.getCmp('component2').add(new Ext.form.Checkbox({fieldlabel:"aLabel",
name: "aName"}));
Ext.getCmp('component2').doLayout();
...
Both components (component1,component") are xtype:fieldset and look exactly the same.
The first component, the DysplayField works correctly but the checkbox doesn't.
Can you help me? Thank you

you may need check the layout of component2. or compare the layout between component1 and component2. Try to set the layout as the same.

Related

Symfony Form add just a Label

What is the way of add just label into a form and modify its value with the entity atribute value related to the form. PRE_SET_DATA event is properly executed but I don't know how to set its value. Picture code and result:
Cheers!
There is no way to just add a label (without textArea) dynamically, at least in Symfony 2.8 . I worked it around using an non-mapped disabled text without label.
You have to ADD again the same element name into PRE_SET_DATA function and 'thanks God Symfony' it keeps the order.
Cheers everyone!!

Element Checkbox got its label always to the left and needs a link

How can I change the positions of checkbox and label and how to implement a link into the label?
$acceptGTC = new Element\Checkbox('AGBs');
$acceptGTC->setLabel('I Accept the GTC (show it).');
$this->add($acceptGTC);
regards
n00n
meanwhile:
I tried to overwrite the view helper for checkboxes.
copied
*/vendor/zendframework/zend-form/src/View/Helper/FormCheckbox.php
to
*/module/Application/src/Application/View/Helper/FormCheckbox.php
added to module.config.php
'viewhelpers' => array('checkbox'=>'Application\View\Helper'),
But it still uses the original one...
Do I have to tell zend to use my FormCheckbox?
I don't exactly know the way you are rendering your Zend_Form_Element, but in order to enhance the rendering as you want you should build a custom decorator, and add it to this element.
You should read the Zend documentation on Zend_Form_Decorators, everything is quite well explained and should lead you to a fancy solution.

How to remove a validator from a Select?

I have a form where I need to add/remove validators dynamically. Based on a dropdown selection, other form fields may have different validation rules.
For other kinds of inputs, I've used replace(methodThatCreatesTheInput()) to get rid of a previously added validator. (Not knowing of a better way. Specifically, there doesn't seem to be any way to directly remove a validator from a component...)
With Select, from wicket-extensions, this approach fails with something like:
WicketMessage: submitted http post value [[Ljava.lang.String;#5b4bf56d]
for SelectOption component [8:myForm:targetInput] contains an
illegal relative path element [targetConsortiums:1:option] which does not
point to an SelectOption component. Due to this the Select component cannot
resolve the selected SelectOption component pointed to by the illegal value.
A possible reason is that component hierarchy changed between rendering and
form submission.
The method that creates the Select:
private FormComponent<?> targetSelection() {
Map<Class<? extends Target>, List<Target>> targets = targetService.getAllAsMap();
SelectOptions<Target> propertyOptions = new SelectOptions<Target>("targetConsortiums",
targets.get(Consortium.class), new TargetRenderer());
SelectOptions<Target> consortiumOptions = new SelectOptions<Target>("targetProperties",
targets.get(Property.class), new TargetRenderer());
Select select = new Select(ID_TARGET, new PropertyModel<Target>(model, "target"));
select.add(propertyOptions);
select.add(consortiumOptions);
select.setRequired(true);
select.setMarkupId(ID_TARGET);
return select;
}
(Why use a Select instead of normal DropDownChoice? We want the two types of choices to be clearly separated, as documented in this question.)
Any ideas how to solve this? What I'm trying to achieve is, of course, very simple. Unfortunately Wicket disagrees, or I'm using it wrong.
Wicket 1.4.
I don't know how to do this on Wicket 1.4, but on Wicket 1.5 there is a remove method for validators on FormComponent (see javadoc)

How to add IDs for Tabs in Tabpanel in GWT?

I am trying to set ids for tabs in the tabpanel. The code that I have written is:
Panel dateTab = new VerticalPanel();
queryTabPanel.addTab("Date", dateTab);
where queryTabPanel is another TabPanel.
My Problem: is to set Ids for the Tabs. So that I can click on the 'Date' tab in the tabpanel.
What I have tried : is by manipulating DOM like :
DOM.setElementAttribute(productTab.getElement(), "id", "Swagatika");
But that does not seem to be working. :(
Has anyone any idea if that is possible, if so How difficult is to add IDs.
Thanks in advance.
For testing using WebDriver, you're supposed to use a special module that <inherits name="com.google.gwt.user.Debug"/> (see "Renaming module" in the GWT DevGuide), and call ensureDebugId on your widgets.
In your case, after calling queryTabPanel.ensureDebugId("queryTabPanel"), the first tab would have an ID of gwt-debug-queryTabPanel-bar-tab1 (see TabPanel.html#onEnsureDebugId for the details).
In addition to the Debug flag you need to use TabLayoutPanel.getTabWidget(...) and use ensureDebugId on it like the following:
SimpleLayoutPanel newTabPanel = new SimpleLayoutPanel();
tabLayoutPanel.add(newTabPanel, "Date Tab");
tabLayoutPanel.getTabWidget(newTabPanel).ensureDebugId("MyDateTab");
Notice that setting the debug ID before adding the Widget to the tabLayoutPanel won't have any effect. Also make sure to use getTabWidget(..) and not getWidget(...).

DropDownList inside TELERIX AJAX bound grid doesn't work (all EditorTemplates) ASP.NET MVC2 extensions

I have a telerik Grid, AJAX binded.
I've added an EditorTemplate to create a DropDownList.
When I push edit / insert in the grid - I can see the DropDownList, but when I try to use it - it doesn't work.
so I've added an int test to the viewmodel, decorated it with the same UIHINT,
and added it to the view.
The DropDownList works great.
What can cause Telerik's grid to disable that activity ?
I've the same problem with the DateTime component, I get the "button" to show the component, but pressing it yields nothing.
UPDATE: changing the DropDownList from :
Html.Telerik().DropDownList()
.Name("ActivityID")
.BindTo(new SelectList((IEnumerable)ViewData["DropActivities"], "Id", "Name"))
to:
Html.DropDownList(null /* the "name" should be null - proper "name"" attribute will be set by the runtime */,
new SelectList((IEnumerable)ViewData["DropActivities"] /*a list of all employee names */,
"Id", "Name"))
Made it work inside the grid, but... when I try to update, I Get 500 server error.. it looks like the selection doesn't pass well back to the model.
Well, it looks like a confirmed bug with telerik.
Here is the post from their forum: Script Registrar Not Loading Scripts for Controls used in Client Templates
I did applied the patch and it didn't solved the problem waiting for the next version.
EDIT: make sure the bound variable apears only once - that might cause the "lockdown".