Zend 2 - Default InArray Validator of Select Element gets lost - zend-framework2

I have an issue when adding a filter to my select elements in Zend 2.2. When creating a select element, a default validator is added to this element:
This element adds an InArray validator to its input filter specification in order to validate on the server if the selected value belongs to the values.
This works fine until I add a custom filter to that element:
$filter = new Input('element_name');
$filter->setRequired(true);
$this->add($filter);
This Zend\InputFilter\Input is added to a Zend\InputFilter\InputFilter which is later added to my form. From now on the default validator is lost.
How can I add a filter to form elements without losing their default validators?
Am I missing something? I don't expect this as the default behaviour, because everyone is desperately asking how to deactivate it. There's even an attribute to deactivate it ('disable_inarray_validator'), however, I want to keep that validator without passing all my entries of the selectbox to my InputFilter. Also I didn't find anything in the Zend 2 documentation. I guess the solution must be something simple. Thanks in advance.
Note: Same happens when I add the InputFilter with the InputFilterManager to the form.

Please see my comment on your question first. Only thing I thought might work that I haven't tried to get this to work is:
$input->getFilterChain()
->attachByName('stringtrim')
or
$input->getFilterChain()
->attach(new StringTrim())

Related

How to check if there is a duplicated field name within my form before register?

I am trying to identify whether within my react final form I have a duplicated name field and then throw an error. I have tried to use a decorator on registerField() and it seems to work fine, however, on a re-render this will not work. I have also tried to use getRegisterFields() but it seems like its either removing duplicate names or it never registers 2 fields with the same name.
What would you think would be a perfect approach here? Much appreciated.

Why do issue view page requires an extra refresh to see the customfield value?

I am updating my custom field pro-grammatically if custom field is left blank. I found a question on stack related to this which helped in saving/updating custom field value correctly.I referred this stack question .
As I said I am updating custom field if it is left blank. So I have written some java code which checks if custom field is null if yes then I am generating some values using java code and updating and saving value in database. This all is working fine. I am doing this all when create issue.
But when issue page is rendered the respective custom field is not displayed,it need an extra page refresh for that. After page reload the custom field is rendered on page with correct value.
Any ideas? Why page reload is required ?
Can some point me to write direction ?
I am using JIRA 6.0.x
I am writing code in MyCustomField extends AbstractSingleFieldType class and using its getVelocityParameters method
Check your log files for errors seen the first time the screen is loaded? May also be errors shown in the JavaScript console? Otherwise strip everything back to be as simple as possible and then add complexity back in until it breaks in the same way.

How to customise naming of symfony 1.4 form elements

I know this is possible but I can't seem to find the right search string to get the answer online.
I have MyForm()
and I want to create 5 of these rendered within the same form so I want to change the naming structure of the form elements thus:
name="forms[1][fieldname1]"
name="forms[1][fieldname2]"
name="forms[2][fieldname1]"
name="forms[2][fieldname2]"
etc
so that when it is submitted I can just iterate through the $_POST['forms'] array, binding each one to a MyForm instance and validating.
I'm sure you can customise he naming of fields for symfony forms in some global way rather than going through each widget but I just can't find it on the web.
Anyone point me in the right direction?
Thanks.
Solved own problem :
$this->widgetSchema->setNameFormat('my_form[][%s]');

SmartGWT: Checkbox Tree - the proper way to get selected checkbox value

SmartGWT has this property for a TreeGrid object:
employeeTreeGrid.setSelectionAppearance(SelectionAppearance.CHECKBOX);
This by default 'prepends' every nodes (including root) with checkbox.
(Just making myself clear.)
Also, I am aware of this similar solved question:
GWT tree with checkbox:How to get all checked tree items?
However, I do not seek this kind of solution..
What I'm looking for is a more efficient way, where I don't have to loop through 1000 items.
Is there any way to do this, if possible, using the widget I am using now?
If not, is there any other way, using other widget?
Thank you very much!
I think as you use SelectionAppearance.CHECKBOX you tell to the grid that the selected records are marked by the checkbox field value. So every time you check one you select a record.
You can get the set of selected records by either getSelection() method or getSelectedRecords(boolean) because of deprecation of the previuous one.
You can have a look at the code of this example of the smartgwt showcase.

Dynamic embeddedForm

I'm looking to add an embeddedForm dynamically in Symfony 1.4 using Doctrine.
What I'm mainly looking to do is:
1) Only show the relation based on whether or not a checkbox has been ticked
2) If checked, show the embeddedForm
3) Have then the ability to add a new embeddedForm or delete an existing form
I have seen ahDoctrineEasyEmbeddedRelationsPlugin, which looks pretty good with los of configuration. The only problem was that 'newFormsInitialCount'=> 1, means that there is always 1 form as default. I need 0 forms as default and only.
I've also seen a couple of tutorials, but all seem to have at least one relation by default.
For me, the embeddedForm needs to be OPTIONAL, and only display when needed.
Thanks
Follow information based on these links :
http://www.thatsquality.com/articles/stretching-sfform-with-dynamic-elements-ajax-a-love-story
http://www.symfony-project.org/more-with-symfony/1_4/en/06-Advanced-Forms#chapter_06_sub_the_form_saving_process
First is about adding "subforms" with ajax, derived from second you could hide the unneeded form fields and toggle them per javascript (e.g. jQuery.toggle())) !

Resources