Symfony2: Add data attribute to select options - symfony

I'm currently working on a Symfony2 project. I've set up a form with a select field and some options loaded from the database. Now I want to add a data attribute to every option of this select field which is needed by a JavaScript.
I know how to make "static" changes to the form layout, however I need a different attribute for every option now - what changes do I have to make in my twig template?

Found a solution that fitted my needs here: https://github.com/symfony/symfony/issues/3836#issuecomment-23145270

The template is not the best place to do this. Instead, modify the form before presenting it. See How to Dynamically Modify Forms Using Form Events. Lots more flexibility there.

Related

NetSuite Integration Through Asp.net

I am doing NetSuite Integration for my product in ASP.NET.
I have created a Custom List in NetSuite account and I want to add values to this list through ASP.NETcode.
Please someone can help me with the sample code ?
The easy fix is to just convert the custom list to a custom record. There is a checkbox for that on the custom list editor screen. Then you can add values as you normally would for a custom record. Totally supported and logical to do if the list elements vary.
This URL will show you how to add values to a custom list, manually. https://netsuite.custhelp.com/app/answers/detail/a_id/10069/kw/create%20custom%20list.
According to this page (https://netsuite.custhelp.com/app/answers/detail/a_id/10242/kw/suitescript%20update%20custom%20list), SuiteScript does not allow custom lists to be edited. I have, previously, found ways around what they say can't be done. Though, that is only advisable if you want to keep updating the code to make sure they don't break it with updates... :)

ASP.NET DynamicData edit logic for depending fields

I want to control some fields in a dynamic data edit page.
So for example :
when a specific type is chosen in a combobox, other input fields should be disabled or should be set to a specific value.
How should this logic be implemented, a custom edit page ?
Or can it be controlled from the model metadata ?
Usually the best path in Dynamic Data it's to act on the metadata side; the basic enviroment don't implement every requirement you've listed but it's relatively easy to add those functions if you check the work done here:
http://csharpbits.notaclue.net/
The main point of the DD it's the templating system: going the custom page route too easily/often, in my opinion, defy that point.
F.

Setting formatting on multiple controls in a InfoPath form at one time

I am creating a form that needs to have 30 or more fields either disabled or set to be read only. They need to be marked as such if the based on the value of a drop-down box.
This is something that I can do using conditional formating that I know, what I want to know is there a way to either add conditional formatting to multiple controls at once or a rule that I can set that will accomplish the same thing?
One requirement is that I can't use programming code to do this. I realize it would probably be far easier to do that way but that is a requirement given to me by my manager.
EDIT: Forgot to add this there are fields that still need to be edited when the other fields are read only.
One feature in InfoPath 2010 (can't remember if it was in 2007) that reduces the pain of this sort of repetitive work is the ability to copy-and-paste rules. With this you can create your read-only rule once and then just paste it onto each of the 30 controls that need it.
You could put it all in a section but your only option for sections is hide/show (not disable or read only). Otherwise you have to setup all the fields against that one dropdown. Huge pain but at least you only have to do it once.
An alternative, which is just about as much work, is to setup two views. One that is readonly and one that is normal. When the user changes the dropdown just flip the view. This method has a bunch of display nuances but does work.

drupal form alter in webform forms

I know that there is possible to use some functions to alter drupal core forms: hook_form_alter().
Can we use this with Drupal forms that are created with the Webform module?
In Drupal 7, you can either use hook_form_alter() or hook_form_<formid>_alter(), which ever you prefer. Just make sure you get the naming and parameters right. Drupal 6 only supports hook_form_alter() however.
When you create these functions, also remember that Drupal may not always pick up on them until you've flushed the cache.
Another important thing to note is that if you want to make changes to the webform fields, you have to make changes in $form['submitted']. I made the mistake of originally trying to edit $form['#node']->webform['components'], which has no effect.
More information can be found here: http://drupal.org/node/1558246
Hope that can help.
You can do it,
you just need the id of the node and then use the id like in
hook_form_<FORMID>_alter()
the FORMID generated is webform_client_form_<NODEID>
where NODEID is the id of the node
so if you have a module named mymodule and a node with id 44 which has a webform
function mymodule_form_webform_client_form_44_alter(&$form, &$form_state) {
// code here;
}
You can use hook_form_alter(), accessing elements via $form['submitted'].
I am not quite sure what you are trying to do, but since webform module creates a content type - webform - you can alter forms created by webform purely through the admin interface - add new inputs and input types, specify whether they are required or not etc.
for example, a "contact us" form can have whatever inputs you want - unlike the core Drupal contact form which IIRC only has an email address and a textarea.
Yes, if for some reason you need to make a change to the webform which you can't do by editing the webform node, then you can use hook_form_alter to change the form as well, as the webform is created by the form api.
That said, do poke around in some of the corners of webform - it comes with a number of options for dynamically filling or changing parts of the form already.

Custom search form in Drupal 6: Views/Panels or custom sql?

I use CCK in Drupal 6 and I need to build a search form in Drupal with 8-10 fields used as a filter. When the user submits the form I need to make a query on the DB applying filters and presenting the result on a table.
I know how to do this programmatically by building dynamically the SQL-where condition (joining node and content_type_xyz tables) but I would be interested in learning how to do it in the "Drupal way". I think I would have to use Views and Panels but I don't know if they can be easily implemented in situations like this. I've tried to build some sample views but I think to be faster in creating code by hand.
If you want custom searches you need IMO to do 2 things:
Hook yourself into _search so you can use Drupal's display for the results. Inside this form, you can create your queries for the database or load other content as you wish, just be sure to use pager_query.
Extend the search form that already exists or built your own. I suggest buliding your own. use what is already existing from Drupals search form. This way, you have a clean way of how to do this.
There is actually no need to use any fancy modules (that doesn't mean you should rule them out, but a search is something so esential that it is quite well handled with the basics).
Using the above, you'll get a native search form with all it's power and can make use of global paging options.
If you do it using views you will only be limited to the filtering you can do using SQL. Views is an SQL builder, and does not contain any 'proper' search functions. That said, it sounds like Views will do what you want; if you create filters under views and then click 'Expose this filter', you will suddenly see fields that allow the user to enter something to filter by appear.

Resources