Just curious...
I have a project where people can input their cooking recipes. I would like to build a webform that will have a textfield and when it is filled in a new textfield appears below. A "growing textfield list". Let me try to show it here:
Ingredient #1 _________________________________ [add]
When you type and ingredient click "add" you then are going to see:
Ingredient #1 Potatoes_________________________
Ingredient #2 _________________________________ [add]
Sorry for not knowing the proper markup. However if anyone knows:
a) the proper term for this ( I call a growing textfield list )?
b) how to do it with webform in drupal?
There are two ways of doing this without any programming:
If you are using the Webform module (not sure if by webform you mean the node form or the Webform module) then you can try the Webform Add More module which enables what you want. The only downside is that it works only with fieldsets so you'll have to put your textfield in a fieldset and enable the add more functionality on that fieldset.
If you are using CCK then it's really simple: just add a new textform field and set it's number of values to be "Unlimited". However I would use something like Hierarchical Select which would allow users to reuse ingredients, add new ones and it would also allow you to categorize them.
Related
I have a master/detail relation similar to the relations sample provided.
In my example department has a one to many relationship with employee
I have a form widget(department) which has a button to insert an employee.
when I click on that button the correct dialog form is displayed but I am allowed to enter any department which I do not want.
I am looking to have the relation defaulted to the "parent" widget where it was clicked and ideally not be editable.
It's hard to give an exact answer without seeing your app, but you should probably replace the dropdown in the form with a label, that will make it not editable. You can bind the value of the label to the relation just like the value of the dropdown was bound.
A slightly easier option would be disabling the dropdown (look for the Enabled probably in the property inspector). But that could be confusing for your users since they might think it should be editable.
(Alternatively, you could just remove the field altogether if it's not important to show the relation.)
I think this only answers the "not editable" part of your question, if you want it to be pre-filled you either need to do some scripting, or use relation data sources.
I suggest using relation data sources, so right now you probably have something like:
app.datasources.Emp.create(), which creates a new employee.
Instead, you can use widget.datasource.relations.Emp.create(), which will create a new employee which has a relation to the current item in widget.datasource. If this button is placed in your department form widget, then that means it will create an employee related to whatever department is shown in the form.
Note that none of this stops users from changing the department of an employee, it just changes the UI. In lots of cases that is enough, but you may also want to add some server-side security controls if it's important to limit which users can create employees, change departments, etc: See https://developers.google.com/appmaker/security/secure-app-data
I have a CompositeField consisting of a LinkField and TextField in my dialog.
On select of data for LinkField, I want to populate the TextField also with a value related to the LinkField value.
Any idea how to do this?
This is for Magnolia CMS. I'm using the latest Magnolia version.
Thanks! :)
There is no ootb binding between different fields.
To create it, you would either need to write your own field that will internally encapsulate the link field and text field and register listener for link field value change and upon change set value for the text field.
Or you would need to rewrite dialog presenter to be able to register such listener on the link field when it's being created.
Sorry, don't have any code samples at the moment to demonstrate it. Hope the explanation is clear enough.
HTH,
Jan
Do you need to update the text field in view of the editor?
If not, this can be easily achieved by modifying the save action. Your form should have a commit button defined with class=info.magnolia.ui.admincentral.dialog.action.SaveDialogActionDefinition
Open SaveDialogActionDefinition and you'll see it points to info.magnolia.ui.admincentral.dialog.action.SaveDialogAction which, when executed, can manipulate the node before saving the session.
If you extended SaveDialogAction, added another method similar to setNodeName(Node node, JcrNodeAdapter item) and called it between setNodeName(...) and node.getSession().save(), you could set any additional property you wanted based on those entered by the user.
You would also need another definition class that referenced your new action so your dialog definition knew to use the new action on commit.
I'm creating 2 content types: 'Event' and 'Speaker'. An event has multiple speakers.
For the relation I'm using the entity reference module.
I want to make a view where I can see an event with the speakers' information, picture, ..
Someone told me to use display suite too, but I don't really know why I would need this.
What would be the best approach?
Thanks in advance for your help! :)
Simon
You can definitely do this with views: display the fields of a referenced node in a view.
Create a view that displays all the fields you want from your event, but then, to be able to pull the appropriate speaker fields for that event, you'll have to add that speaker relationship.
Go to the 'Advanced' section of your view and click on 'Add' next to 'Relationships'
Select 'Content: Speaker' or whatever the exact name of your referenced field is
Now you should be able to see and select any of the 'speaker' field from the field list, but make sure when you choose one of the speaker fields, that you select for the 'Speaker' relationship to be used when displaying it. It's an option on the field settings page.
Does that work for you?
Yes, you can do this with Views.
But since you're using the Entity relationships, you need to add two relationships in your view. One for the relationship from 'Event' to the 'Entity' and another from the 'Entity' to the 'Speaker'. It's like adding a Many-to-Many join table.
Make a view of Events
Make an Entity relationship between Events and Speakers
Add a relationship between Event and the Entity Relationship
Add another relationship to Speakers that uses the relationship from step 3
Add whatever fields you need from the Speakers nodes.
Hope that helps. I got stuck on that for a long time myself.
The main issue is going to be managing 'duplicates' if you have more than a 1:1 relationship. You might be able to manage that with the "Use Aggregation" feature.
An alternative I came up with for an outdoor activities site I was working on ( http://dev.naturefitter.com/packages ) that avoided the duplication issue was to use Views Field View ( http://drupal.org/project/views_field_view/ ). I created a main view (in my case 'Packages') and a subsequent sub view ('Activities') that takes a contextual filter from the main view. The sub view is a block that has the fields from the Activity content type and a contextual filter that expects the nid from the package content it's attached to.
Best,
Pat
I'm using Profile to add a "Department" field to user profiles.
I'm using Views to create a view of users, with "Department" being an Exposed Filter.
The Exposed Filter is a textfield. I'd like for it to be a select dropdown that is populated with all possible values.
Is anyone aware of a module that will alter Views filters, changing fields from textfields to select dropdowns?
Drupal 6. Views 2. The profile field is a single-line textfield (with autocomplete).
i had the same issue in a project
fields that are textboxes show be select box.
as attachment image shows in 'FILTER CRITERIA' choose your field
in 'Filter type to expose' part choose 'Grouped filters'
a table will be shown that you manually can add your data as options
this solution is good when you know your options
this is my RTL settings for expose a textbox filter
this is my RTL settings for expose a textbox options
and in UI - client side this field will be shown like this
What kind of profile field is "Department"? I'm assuming it's one of single-line textfield, multi-line textfield, checkbox or list selection. I only tested it with a list selection, but if you check "Force single" then the exposed filter will be a select dropdown.
Assuming you mean Drupal 6. The above is true with Views 2.x and 3.x on D6.
If you want to modify an existing filter, follow the accepted solution provided here.
If altering an existing filter does not satisfy your requirements, then this step-by-step tutorial will help you creating your own custom Views filter.
I have a special content-type that I have created, and one of the fields is a radio button list. The last element is named 'Other' and I would like to have a textbox appear and allow the user to enter in a non-defined value.
Is this sort of capability provided by any sort of module, or is this something that needs to be coded by hand? (If so, would you mind pointing me in the correct direction?)
The CCK Select Other module appears to get you most of the way there. I imagine it could be modified to work with radios fairly easily.