How to create quite complicated form in symfony2 - symfony

I need to create form in symfony2 which should look like form on this image http://imageshack.us/photo/my-images/805/formy.png/
As you can see there is dynamic list of products and as a part of this list there is dynamic list of options with dropdown list. Just now I have dynamic list of products, according this tutorial http://symfony.com/doc/2.0/cookbook/form/form_collections.html and it works fine. How can I add dynamic list of dropdown lists?
thank you

This it not a real solution to your answer if you want to use the default Form class in Symfony.
But... why don't you consider creating a custom form? Like you do it in HTML. On submit the form, you can get the values just like you do it in PHP...
$_POST['something] or $_GET['something]

Related

Use dynamics fields in Google Form

I have a question about google form.
I'm creating a form where I would like to insert dynamic fields, let me explain.
I would like these fields to be shown or hidden dynamically and made mandatory based on a condition. I don't want to use conditional sections. In short, I would like to create a structure similar to the one in the following example:
Field when I choose "SI"
Field when I choose "NO"
Is there any way to accomplish this? Maybe with an add-on?
Thank you!

Add custom form data to Drupal module without using CCK fields

Iam very new to Drupal 7 so bear with me. I have created a jQueryUI drag and drop interface with JQueryUI tabs. My problem is i cant find the correct hook to add this custom interface to the admin interface. Like so (mockup) http://onlinemedia.rmcad.edu/sandBox/screenshot/screen-shot.jpg
All the examples I find are using CCK fields. CCK fields are great but they dont have this kind of custom functionality I want or does it?
Any help would very much be appreciated.
J
cck is drupal 6, not 7. to add to the node creation form you could use hook_form_alter or hook_form_ID_alter.
Check the form api documentation to get an idea of how to add stuff to the form object in either of those hooks.
From your mockup I understand you intend to add this drag&drop interface to a content-type.
If that's the case, I'd recommend you to add the appropriate fields first. Those would help storing the data in Drupal way, once the node is saved.
Once you are satisfied with the fields collecting the data you need, create a module and use hook_form_FORM_ID_alter hook to integrate your "interface", the presentation layer by altering those fields.
If you don't want to add CCK/Field components to store your data how about you create your own database table and store your custom data in there?
This approach is a long one but I have used it to great effect on a very big and complex project.
You will need a custom module with an install script which contains the details of your custom database table.
Forgive me but I don't remember the hook for altering a node-edit-form but that is where you input the code which implement your drag-'n'-drop elements.
Then, you could save the settings altogether when the node-edit form is submitted but I think it's probably better to implement some AJAX to save the settings to your custom database table. So, when a component is dropped into it's final resting place, you use AJAX to save that information to the database.
When a user comes back to edit that page, you simply load your custom settings and apply them to the drag-'n'-drop features and their previous configuration(s) would be visible to them.
I do hope that makes sense and it helps you.

Drupal 7: Creating a taxonomy filter using checkboxes

I'm looking to create a page with a taxonomy filter using checkboxes and when one or more checkboxes is ticked this creates the list of pages below that are tagged with the chosen taxonomy. E.g The filter may contain categories A, B, C, D and E as checkboxes. If the user ticks Category A and Category D then clicks a submit button all pages that are associated to A and D will be listed below.
Seem to be struggling using both methods! Has anyone got a tutorial or step by step guide I could use? Otherwise, can someone help with the following questions?
I created the form in block--block--1.tpl.php by getting the taxonomy tags using taxonomy_get_tree(1); and looping through these to create the checkboxes. I was hoping I could then somehow get the post data and create a list of events (pages) which contain the tags selected. Where would I do the PHP for this? I'm guessing it wouldn't be within the template file so would it be in my custom module? If so, how?
I was thinking of creating a form and using hook_form_FORM_ID_alter but how do I create the form using the taxonomy tags? How do I then add this form into my block?
Any other options?
Thanks
Another option would be using a Faceted Search solution like http://drupal.org/project/facetapi. It works with any underlying search solution, including SOLR if you have big volumes.
You can do this using the excellent Views module. Views lets you create custom lists of content that you can set to be filtered by the user. There's a good article on building a filterable list with views here.
http://www.advomatic.com/blogs/amanda-luker/build-filterable-staff-directory-drupal-6-or-7
You should be able to easily adjust this tutorial to include checkboxes instead of drop downs.
TO change the filter from select to checkboxes I done the following:
function mymodule_form_alter(&$form, &$form_state, $form_id) {
switch ($form_id) {
case 'views_exposed_form':
$form['tid']['#type'] = 'checkboxes';
break;
}
}

drupal replacing default nodes with views page

I have created a page view using field style to display a list of teasers as I want. fields configuration in views allows us to link the field to it's node. but what if we have created view for node detail page and want field to link to it's relevant view.
I had the same question, and after a bit of research this is what I've concluded:
The views module isn't intended to replace a default node view. I say this because of the level of difficulty involved in doing this and the lack of information on how to accomplish this. Ryan Weal has posted a way to accomplish this by editing your node template that doesn't look too difficult to accomplish, and here is the link.
However, it seems that a more popular solution, especially if you are like me and don't like to get into editing theme files. You can use the Display Suite module to effectively reformat the default node content as you would like.
I'm not sure if I understand you properly, but it sounds like you are wanting to display a view in a page view of a node?
In order to do this, you could:
create a small module, using hook_nodeapi() or one of the D7 replacements for this function in order to insert the output of the embedded view into this page's content, by conditionally adding a $content element when the node is of the appropriate id
or (easier, but requires allowing input type PHP) embed the view right on the page.
http://thedrupalblog.com/embedding-view-drupal-6-using-views-embed-view for information on embedding views

Drupal 6: Altering a CCK form on a page created by the menu system

I'm a drupal newbie (but experienced with PHP). I've created some functions to display pages and mapped them onto urls using menu functions.
In one of these functions, I'd like to grab a form for a CCK content type, have my way with it, and spit it out onto a template.
So I have a function projectadmin_create_page(), which grabs a reference to the form using:
$form = drupal_get_form('project_node_form'). Here I'd like to alter it (or create a new form based on it) and send it off to the template. As a first step, I'm passing it straight to the template. Here, the form tag along with all the hidden fields get output, but none of the field tags.
My hope was that I wouldn't have to rewrite all the validation for the CCK form, but still get a custom page.
Can anyone provide some guidance?
you can alter any Drupal form with hook_form_alter [1, 2]

Resources