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.

Comments

Status:Needs review» Needs work

Hmmm... 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 ?

Version:6.x-2.0-rc3» 6.x-2.x-dev
Status:Needs work» Needs review
StatusFileSize
new2.52 KB

Ah, 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.

StatusFileSize
new2.59 KB

Re-rolled.

Status:Needs review» Postponed

This 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.

This 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.

StatusFileSize
new2.61 KB

one more re-roll

EDIT: working sweet, thanks ;)

Thanks a bunch but ... how do i install this patch??

Version:6.x-2.x-dev» 6.x-2.0
StatusFileSize
new2.59 KB

Here's another re-roll against Ubercart 2.0.

That's a beautiful thing. Thanks!

StatusFileSize
new4.83 KB

Works 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.

StatusFileSize
new4.83 KB

This 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.

oops. I just patched my test site on my pc and got these error messages:

# warning: include_once(./sites/all/modules/ubercart/uc_attribute/uc_attribute.module) [function.include-once]: failed to open stream: Permission denied in C:\Programs3\drupal\wamp\www\drupal-6.10\includes\bootstrap.inc on line 617.
# warning: include_once() [function.include]: Failed opening './sites/all/modules/ubercart/uc_attribute/uc_attribute.module' for inclusion (include_path='.;C:\php5\pear') in C:\Programs3\drupal\wamp\www\drupal-6.10\includes\bootstrap.inc on line 617.
# warning: include_once(./sites/all/modules/ubercart/uc_attribute/uc_attribute.module) [function.include-once]: failed to open stream: Permission denied in C:\Programs3\drupal\wamp\www\drupal-6.10\includes\bootstrap.inc on line 617.
# warning: include_once() [function.include]: Failed opening './sites/all/modules/ubercart/uc_attribute/uc_attribute.module' for inclusion (include_path='.;C:\php5\pear') in C:\Programs3\drupal\wamp\www\drupal-6.10\includes\bootstrap.inc on line 617.

Patching went fine with no errors. I tried running update.php, but that ended up in a fatal error.

So, 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.

sites/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.

Maybe 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.

Yep, 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.

Great 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!

Version:6.x-2.0» 5.x-1.9
StatusFileSize
new11.45 KB

Here is the code for drupal 5

Version:5.x-1.9» 6.x-2.x-dev

The initial patch and discussion was against the Drupal 6 version. Changing the version back to D6.

Hi is it possible to add a Date field?

Hi how did you manage to add a date field?

Ignore 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

Just 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!

When 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

If 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

@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

As 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.

I 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.

The 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.

Version:6.x-2.x-dev» 7.x-3.x-dev
Status:Postponed» Active

Reopening 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.

I 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.

I 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!!!

Has 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).

+1
I also need an attribute field that can hold more than 128 characters.

StatusFileSize
new4.07 KB

This is a simple re-roll of the patch in #12 against 6.x-2.x for anyone needing this functionality right now.

Have 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.

The 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

StatusFileSize
new4.2 KB

Update 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.

Status:Active» Needs work

Patch 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.

Sorry TR, as I noted in #36 the patch in #39 is for 6.x. I'm not using Ubercart on 7.x.

That 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.

Hi 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

@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 use git apply patch-name.patch

Fenstrat: 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?

@bogorman Got it, you need the patch in the root dir of ubercart, not uc_attribute.

Fenstrat. 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?

@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.

Fenstrat. 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?

@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

@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?

@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.

@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?

@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.

@fenstrat. Thanks so much for your help. Will let you know if I have problems.

@longwave. Also thanks to you

StatusFileSize
new4.16 KB

Here's an update of the patch in #39, no changes, just applies cleanly to ubercart-6.x-2.9.

... and we're back to where we were in #40.

@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.

#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.

@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.

+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?

I 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.

To 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.

Any 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()

i just did as per #64 and it works great drupal 7........... i dont get any errors so far dont know why!!

Textarea 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?

An alternative solution is Ubercart Webform Checkout Pane.

Issue summary:View changes
StatusFileSize
new874 bytes

It might be nice if the textfield would display the first option as its default text, maybe not the cleanest solution but something like this ...