Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Right now, the only display type options for attributes are "text field", "select box", and "radio buttons". Adding "text area (multiple rows)" is a very simple task—simply adding another option to the _uc_attribute_display_types() function and fixing a few references in the attributes module where it references the type index. I am submitting a patch which adds textarea support, and I've tested it on the 6.x-2.0-rc3 version. Works great.
Comment | File | Size | Author |
---|---|---|---|
#69 | default_text_for_text_field-496450-69.patch | 874 bytes | britter |
| |||
#57 | 496450-57-textarea-attributes.patch | 4.16 KB | fenstrat |
#39 | 496450-39-textarea-attributes.patch | 4.2 KB | fenstrat |
#36 | 496450-36-textarea-attributes.patch | 4.07 KB | fenstrat |
#19 | uc_attribute.zip | 11.45 KB | talance |
Comments
Comment #1
andreiashu CreditAttribution: andreiashu commentedHmmm... I think you should take into consideration that the latest dev version of Ubercart has support for checkboxes. Your patch is probably against an RC version of UC, right ?
Comment #2
joelstein CreditAttribution: joelstein commentedAh, I was working on the RC3 version, and didn't realize that checkboxes had been added. Great! Here is an updated patch against the DEV version.
Comment #3
joelstein CreditAttribution: joelstein commentedRe-rolled.
Comment #4
rszrama CreditAttribution: rszrama commentedThis seems like more than just a simple consideration because of display difficulties that need to be addressed. i.e. a large block of text could screw up things like the shopping cart display on the cart, checkout, and review forms and the order display. I don't think we should be distracted with these things at the moment, but feel free to propose a solution that might be suitable for when 3.x development opens up.
Comment #5
sendmycard CreditAttribution: sendmycard commentedThis is exactly what we need for our site Send My Card, so that people can enter separate messages for each birthday card they buy. "One man's meat is another man's poison" Having seen other people looking for this, I know I am not the only one who would be grateful to see it.
Comment #6
marcoBauli CreditAttribution: marcoBauli commentedone more re-roll
EDIT: working sweet, thanks ;)
Comment #7
UNarmed CreditAttribution: UNarmed commentedThanks a bunch but ... how do i install this patch??
Comment #8
rszrama CreditAttribution: rszrama commentedhttp://drupal.org/patch/apply
Comment #9
joelstein CreditAttribution: joelstein commentedHere's another re-roll against Ubercart 2.0.
Comment #10
jfinkel CreditAttribution: jfinkel commentedThat's a beautiful thing. Thanks!
Comment #11
regx CreditAttribution: regx commentedWorks great, but stops uc_query from performing calculations like shipping, taxes etc.
Here is a patch that fixes this. Now to get it so multiline fields actually display that way in the cart and order pages.
Comment #12
regx CreditAttribution: regx commentedThis is an update to the previous patch that fixes newlines so they do not break uc_query.
I used /[\r\n]/ in my regular expression which is what I wanted at the time because I was just trying to get this to work.
Just replacing /\r\n/ however is sufficient and will not create extra newlines like the above.
To style you attributes in the cart so the newlines display, but the content still wraps just add something like the following to your template css:
/* format items in cart */
ul.product-description li{
white-space:pre-wrap;
}
I hope this saves someone my frustration when I noticed that totals where no longer calculating correctly.
Comment #13
vitis CreditAttribution: vitis commentedoops. I just patched my test site on my pc and got these error messages:
Patching went fine with no errors. I tried running update.php, but that ended up in a fatal error.
Comment #14
TR CreditAttribution: TR commentedSo, does sites/all/modules/ubercart/uc_attribute/uc_attribute.module exist on your machine or did you accidentally rename or delete it as part of the patching process?
There's nothing in the patch that would have caused this. Which you can confirm by rolling back the changes made by the patch.
Comment #15
vitis CreditAttribution: vitis commentedsites/all/modules/ubercart/uc_attribute/uc_attribute.module exists on my pc
uc_attribute.module and uc_attribute.admin.inc were modified at 10:33am 12/14, when I applied the patch
The patching went well, with no error messages, no hunks failed...
To undo the patch, I moved the uc_attribute folder outside my installation to a "removed files" folder. Then I copied the uc_attribute folder from the same download of ubercart to the proper place. I had installed a new dev of ubercart last week.
Error messages are now gone.
Now that you mention it, rolling back the patch would have been better protocol. It is possible that data gets written to the files in the uc_attribute folder.
Comment #16
TR CreditAttribution: TR commentedMaybe it was a permissions problem? Error message was "failed to open stream: Permission denied". Check the group/owner of the patched files. If you patched them as root, for example, maybe Drupal couldn't open them. There really is nothing in that patch which could have caused this error message - in fact I can't think of any change that could be made to the inside of these files that would prevent Drupal from opening them.
Comment #17
vitis CreditAttribution: vitis commentedYep, my bad. Now that I recall, I did apply the patch in a different way that I usually do. I put the patch in the same directory as the files to be patched. Then I used the commands used for patching as if I were in the root directory:
patch -p0 < uc_attribute.module_7.patch
Better to stick with the old habits.
Thank you again for your patch.
Comment #18
TheDarkFlop CreditAttribution: TheDarkFlop commentedGreat stuff guys, exactly what I needed. Two quick quick things.
-Getting a "0" in my textarea. Whys this?
- Looking to make it resizable as well.
Any thoughts on these? Thanks guys!
Comment #19
talance CreditAttribution: talance commentedHere is the code for drupal 5
Comment #20
mrfelton CreditAttribution: mrfelton commentedThe initial patch and discussion was against the Drupal 6 version. Changing the version back to D6.
Comment #21
bryanhidalgo CreditAttribution: bryanhidalgo commentedHi is it possible to add a Date field?
Comment #22
bryanhidalgo CreditAttribution: bryanhidalgo commentedHi how did you manage to add a date field?
Comment #23
remus1 CreditAttribution: remus1 commentedIgnore this one All now working. that will teach me to use IE to download patch works fine using Firefox
Hi
I am working on a test site to see if Ubercart will work better than the cart I am using . Have turned up here because I also need to have a text area for customers to enter a card message in for each product.
I have looked at a couple of pages on patches and have installed Cygwin. Just tried to run the patch number 5 and had this error, have also tried the first patch incase i have to install each in turn but still get the same
missing header for unified diff at line 17 of patch
I am lost any ideas Please.
Kevin
Comment #24
evancooperman CreditAttribution: evancooperman commentedJust ran uc_attribute.module_7.patch on Drupal 6.19 with Ubercart 2 and it worked like a charm, thanks!! The only thing that would be nice is the ability to determine how many lines will show up but as that can be done via javascript easily enough it's not a big deal, and I imagine it would be harder to implement than would be worthwhile.
Thanks again!
Comment #25
chunty CreditAttribution: chunty commentedWhen I try to apply this patch using subversion I get an error about the module not being the working copy - does anyone what I'm doing wrong?
I'm pointing the "apply patch" location at "C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\jmsweddings\sites\all\modules\ubercart\uc_attribute"
Thanks
Chris
Comment #26
chunty CreditAttribution: chunty commentedIf anyone else suffer with the subversion prob I think its something to do with not having access to the original repository - I used this info in the end http://drupal.org/node/99903#comment-695177
C
Comment #27
schiavone CreditAttribution: schiavone commented@talance Thanks for the Drupal 5 patch. Worked like a charm.
Ideas area are a dime a dozen but...
It would be nice to set the description text in the individual node.
Dan
http://www.snakehill.net
Comment #28
kenheim CreditAttribution: kenheim commentedAs stated in #18, I am also getting a "0" in my textareas. I've examined the patch, but can't find where that is coming from.
Comment #29
pvasener CreditAttribution: pvasener commentedI had the same problem with '0' in my textareas. I also wasn't able to fix that with the patch. I ended up modifying the 'default_option' column of the 'uc_product_attributes' table, allowing it to be null and I manually set it to null for my textareas fields (it was originally set to 0). I'm aware it's not an acceptable fix but it may help until someone smarter finds a proper fix.
Comment #30
kenheim CreditAttribution: kenheim commentedThe direct database fix in #29 works for products currently in the database, but there should be a more permanent solution. I am not a developer, but I made every effort to find where the default_option value was being set. I assume that it is somewhere in the patch, but could not find it. Maybe it is because it isn't being set via the patch that we have this problem? Curious how this problem is not present for text fields, just textarea fields.
Comment #31
longwaveReopening this for consideration in 7.x. It would be even better if attributes were extensible through hooks, so things like this could be provided in custom modules.
Comment #32
kenheim CreditAttribution: kenheim commentedI agree that this should be reopened for discussion. It would be nice to have text area included with the attribute module, just as text field is currently. But more pressing would be to identify where this "0" default value is coming from and how to correct it in the code rather than the database.
Comment #33
JohnDoranNY CreditAttribution: JohnDoranNY commentedI am 100% behind that too! I need textareas in my attributes :( and have not done the unofficial patching, hoping it will come out soon!
Actually.. is it at all possible to allow more customization such as.. for example, using the Countries module dropdown list (since the one site I am woring on, country and state are attributes and its been a pain in the........ to enter every country as a seperate 'option' and then the same with city... or being able to do dates with the "Date" module/api that has a popup calendar and can handle many different formats for a date (ie: being able to do day, month, year, hour, minute as all drop down lists prepopulated).. that would save hours of time if we can use those controls as an attribute!!!
Comment #34
JohnDoranNY CreditAttribution: JohnDoranNY commentedHas there been any movement on this? I tried to apply the patch from #12 above for drupal 7 but all I get is no such file or directory (trying against latest dev version from 7/4/2011).
Comment #35
Anonymous (not verified) CreditAttribution: Anonymous commented+1
I also need an attribute field that can hold more than 128 characters.
Comment #36
fenstratThis is a simple re-roll of the patch in #12 against 6.x-2.x for anyone needing this functionality right now.
Comment #37
bogorman CreditAttribution: bogorman commentedHave tried to apply the patch (am using Ubercart 6.x-2.6) and I get these errors:
bsmkbk:uc_attribute brianogorman$ patch < /Users/brianogorman/Downloads/uc_attribute/496450-36-textarea-attributes.patch --dry-run
patching file uc_attribute.admin.inc
Hunk #1 FAILED at 95.
1 out of 1 hunk FAILED -- saving rejects to file uc_attribute.admin.inc.rej
patching file uc_attribute.module
Hunk #1 FAILED at 409.
Hunk #2 FAILED at 1104.
Hunk #3 succeeded at 1115 with fuzz 2.
Hunk #4 FAILED at 1194.
Hunk #5 FAILED at 1222.
Hunk #6 FAILED at 1248.
Hunk #7 FAILED at 1264.
patch unexpectedly ends in middle of line
6 out of 7 hunks FAILED -- saving rejects to file uc_attribute.module.rej
patch unexpectedly ends in middle of line
bsmkbk:uc_attribute brianogorman$ patch < /Users/brianogorman/Downloads/uc_attribute/496450-36-textarea-attributes.patch --dry-run
patch unexpectedly ends in middle of line
patch: **** Only garbage was found in the patch input.
bsmkbk:uc_attribute brianogorman$
Would be most grateful if you could indicate how I can get the patch to work.
Comment #38
fenstratThe patch in #36 is made with Git and should be applied with Git. See the "Applying a patch" section of http://drupal.org/patch/apply
Comment #39
fenstratUpdate to the patch in #36.
The only change is a bug fix which stopped Checkbox attributes from ever being added to the cart. This was due to the patches changes to uc_attribute_add_to_cart_data() which incorrectly standardised newline characters - it did a preg_replace() on $form_values['attributes'], however values in $form_values['attributes'] can be arrays, e.g. for checkbox values. Therefore the preg_replace must only be run on attributes which are not array's. The attached patch makes this change.
Comment #40
TR CreditAttribution: TR commentedPatch in #39 fails to apply to the current -dev.
If textarea is added as an option type, then it needs to be added in *all* places where option types are dealt with in Ubercart. This includes uc_cart_links and all the SimpleTest cases, especially the uc_attributes.test and the uc_cart_links.test. Tests should be updated to include textarea tests, and all Ubercart test cases should run green after the patch.
Comment #41
fenstratSorry TR, as I noted in #36 the patch in #39 is for 6.x. I'm not using Ubercart on 7.x.
Comment #42
TR CreditAttribution: TR commentedThat explains why the patch didn't apply. In the future, if you provide a patch for a version that's different than the version set for the thread, append a -D# to the patch name. So your patch should be 496450-39-textarea-attributes-D6.patch. That will also prevent the testbot from trying to test a patch for the wrong version (when the testbot finally gets over its problems, that is ...).
New features should go into D7 first, then be backported to D6, which is why this thread is set to D7.
But my remarks in #40 hold, regardless of version; any addition to the attribute options needs to address all uses in Ubercart, not just some.
Comment #43
bogorman CreditAttribution: bogorman commentedHi fenstrat,
Thanks. Have set up Git and tried to apply the patch but I get:
patch unexpectedly ends in middle of line
patch: **** Only garbage was found in the patch input
I copied and pasted the patch text to a text file with the patch name. Is this a correct way of doing it, or is the error due to something else.
Brian
Comment #44
fenstrat@TR Sorry, I forgot the D6 suffix on the patch filename. I appreciate this issue needs to get into D7 but we're not using Ubercart on D7 and needed this functionality in D6 now.
@bogorman That error looks like you're still trying to apply the patch with
patch -p0 < patch-name.patch
, instead usegit apply patch-name.patch
Comment #45
bogorman CreditAttribution: bogorman commentedFenstrat: Thanks.
Have used :git apply 496450-39-textarea-attributes.patch. I have the patch in the uc_attribute directory on my local machine and have changed to that directory using cd.
but I get error: no changes.
I have created the patch by copying and pasting from the file which opens from your link and then changed the name from 36 to 39. In spite of the errors, could the changes have been applied already?
Comment #46
fenstrat@bogorman Got it, you need the patch in the root dir of ubercart, not uc_attribute.
Comment #47
bogorman CreditAttribution: bogorman commentedFenstrat. Have installed the Ubercart modules in my modules directory, not in a Ubercart subdirectory in modules. Everything has worked fine since I did this some time ago. Should I create a Ubercart directory within the modules directory and copy all the uc_* modules into it?
Comment #48
fenstrat@bogorman The patch here in #39 is for uc_attribute which is a core Ubercart module which lives in /ubercart/uc_attribute. The patch needs to be applied from /ubercart.
Comment #49
bogorman CreditAttribution: bogorman commentedFenstrat. So I do need to create a new subdirectory in the modules directory named ubercart and copy all the ubercart files into it? Also, as I am at present working on a remote test site, I assume I would then download the ubercart directory, do the patching locally and then upload the directory to the remote site?
Comment #50
fenstrat@bogorman You only need the core ubercart module, nothing more. This patch is for ubercart. Apply the patch from the ubercart directory. If you're still having issue please http://drupal.org/patch
Comment #51
bogorman CreditAttribution: bogorman commented@fenstrat There is no ubercart directory in my modules directory. The modules directory contains uc_aac, uc_attribute, Uc_attribute length, uc_cart, etc. Should I put all of these in a new ubercart subdirectory in the modules directory?
Comment #52
longwave@bogorman: In that case, apply this patch from your modules directory.
But you should have left all the Ubercart core modules inside the "ubercart" folder as it was when you originally downloaded it, by doing this you've made it much more difficult for yourself when applying future updates.
Comment #53
bogorman CreditAttribution: bogorman commented@longwave Is there any disadvantage in creating the ubercart folder now and moving the files into it or is it better to delete all the core uc modules and to "update" ubercart?
Comment #54
fenstrat@bogorman Moving the files back into the ubercart folder or updating ubercart will result in the same thing. If you clear all your caches Drupal should pick up the new module locations. Again, it's really a much better idea to leave ubercart (or any module) as it comes when you download it.
Comment #55
bogorman CreditAttribution: bogorman commented@fenstrat. Thanks so much for your help. Will let you know if I have problems.
Comment #56
bogorman CreditAttribution: bogorman commented@longwave. Also thanks to you
Comment #57
fenstratHere's an update of the patch in #39, no changes, just applies cleanly to ubercart-6.x-2.9.
Comment #58
TR CreditAttribution: TR commented... and we're back to where we were in #40.
Comment #59
fenstrat@TR yep, I fully appreciate that. We don't have any clients using Ubercart on D7, hence the need for this only on D6. If someone else wants to take this and forward port it to D7 that'd be great. But I do not have the time.
Comment #60
TR CreditAttribution: TR commented#40 is not about D6 vs D7, it's about making sure that the added feature is *complete*. Your patch doesn't make textarea attributes available in all places where attributes are used, doesn't address and changes necessary to limit the size of the textarea data or modify the schema so it will fit into the existing table, and it doesn't fix and enhance the current extensive test cases to support textarea attributes. Because of that, this patch currently has zero chance of getting into Ubercart D6 or D7 as it stands.
Comment #61
fenstrat@TR I hear you. However we do not have any resources to apply to further Ubercart development. We simple needed this working patch on D6 for use in a make file with ubercart-6.x-2.9.
Someone please feel free to step up and take the work in #57 and address TR's concerns as per #60.
Comment #62
Alan D. CreditAttribution: Alan D. commented+1 to the feature (pinging to keep this issue alive rather than a silent subscribe)
How much time would you expect it to take to implement this feature completely (very slim sponsorship potential), or are there any Ubercart specific hooks that could be used to completely implement this outside of core Ubercart?
Comment #63
MBroberg CreditAttribution: MBroberg commentedI am using this module for text areas, as long as the attributes do not affect the final price.
drupal.org/project/uc_attribute_cck
This is for 6.x only, so not sure how Drupal 7 users would implement it.
Comment #64
filnug CreditAttribution: filnug commentedTo convert a input text into a textarea with ubercart on Drupal 7, I modified the document :
sites/all/modules/ubercart/uc_attribute/uc_attribute.module
In that document I replace all "textfield" to "textarea". This document should have 3 of them.
It works pretty fine even if it isn't a good way to do it.
I hope that someone will add soon the textarea in option for attributes fields.
Comment #65
glynster CreditAttribution: glynster commentedAny further inputs as to including this into Ubercart Drupal 7? I have manually applied the updates as explained by the latest patch and so far it works with only one error when loading the product page: Undefined property: stdClass::$fields in _uc_field_attribute_nodeapi()
Comment #66
erykolryko CreditAttribution: erykolryko commentedi just did as per #64 and it works great drupal 7........... i dont get any errors so far dont know why!!
Comment #67
jasonabc CreditAttribution: jasonabc commentedTextarea patch works well. Unfortunately carriage returns that are entered by customers in product textarea attributes are not preserved. This example:
Text on line 1
Text on line 2
Text on line 3
is output as this in the cart, checkout and order areas:
Text on line 1 Text on line 2 Text on line 3
This is causing problems for clients who need to see what has been entered by the customer on each line for layout purposes. I can't find a solution to this on DO or Google. Anyone got any ideas?
Comment #68
johnhorning CreditAttribution: johnhorning commentedAn alternative solution is Ubercart Webform Checkout Pane.
Comment #69
britter CreditAttribution: britter commentedIt might be nice if the textfield would display the first option as its default text, maybe not the cleanest solution but something like this ...
Comment #70
rnj786 CreditAttribution: rnj786 commented#12 solution works to display the lines for the text area in the cart. I patched the module for UC3 on Drupal 7, manually changed the query to include IN and applied the CSS from #12 response.
I wonder if this lines display in the order view on the back-end as that would be necessary too.
Comment #71
pipicom CreditAttribution: pipicom commented#64 worked for me.
Comment #72
erykolryko CreditAttribution: erykolryko commentedTextarea patch works well. Unfortunately carriage returns that are entered by customers in product textarea attributes are not preserved. This example:
Text on line 1
Text on line 2
Text on line 3
is output as this in the cart, checkout and order areas:
Text on line 1 Text on line 2 Text on line 3
This is causing problems for clients who need to see what has been entered by the customer on each line for layout purposes. I can't find a solution to this on DO or Google. Anyone got any ideas?
Comment #73
erykolryko CreditAttribution: erykolryko commentedNow "textarea" is causing more trouble in 7x 3.10, read how it is messing up & throwing me errors https://www.drupal.org/node/2890128