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.
Hi,
Now, if we want to remove the video, we need to remove the string from the input.
Would be great to have remove button if field have multiple values. I made some little patch based on field collection module. Not the best one solution I think, but it works.
Comment | File | Size | Author |
---|---|---|---|
#3 | youtube-add_remove_button-2533522-1.patch | 5.89 KB | kedramon |
youtube_remove_button.patch | 5.83 KB | kedramon | |
Comments
Comment #1
guschilds CreditAttribution: guschilds at Chromatic commentedHey kedramon,
Thanks for the patch! I've always thought this form would benefit from a remove button. I've had to add them to other forms and I know how much of a pain it is. I think following the Field Collection's lead is a good idea, I just wish it didn't require 100+ lines of code :). For that reason I'm not 100% sure yet if it's worth the added complexity, but we might as well get a working patch that others can use and we can gauge interest.
I tried your patch and ran into a couple issues:
Because these lines list the full path to the module in your specific installation, it doesn't apply to a checkout of the 7.x-1.x branch. To avoid this in the future, it might be easiest to, once your done with your code changes, check out the repo, apply your changes to it, and then create the patch. More information about creating patches for Drupal can be found here. Those lines should end up looking something like this:
Next, once I applied your patch, I wasn't able to get it to function. I installed a clean Drupal 7 with the YouTube Field module and created an unlimited cardinality YouTube field. I applied the patch and cleared cache. When I click the "Remove" button, the field item isn't removed and this error is thrown:
I haven't spent any time trying to debug it.
And a couple of code style / standardization comments. First:
Lets rename the path to
youtube/ajax
and the functionyoutube_remove_js
. This actually follows the Field Collection module closer by prefixing those pieces with the name of the module.And finally:
There should be a space before and after the
.
in the string concatenation. More about that in the Drupal coding standards.Thanks again!
Gus
Comment #2
kedramonHi Gus,
I worked a bit on this task and fixed my errors, but there is one issue left,
since the video code is pre populated during validation, it is always in field delta description. Will post my patch tomorrow, maybe You give me some idea how to deal with it.
Thanks!
Vova
Comment #3
kedramonHi,
sorry for late posting, here is my patch.
Comment #4
guschilds CreditAttribution: guschilds at Chromatic commentedHi kedramon,
Nice work! I didn't run into any problems when quickly testing #3 and the code changes look good.
I'm going to mark this as RTBC and leave it open so others know they can use it, but as I mentioned before, I'm not sure that I'll be committing it to the module. It's a bummer that it takes 129 lines of new code to pull this off, increasing the size of the .module file by over 20%. I just don't think the feature is worth that increase in size and complexity.
Comment #5
kedramonHi Gus,
ok, thanks for reviewing!
Comment #6
guschilds CreditAttribution: guschilds at Chromatic commentedClosing after a year of inactivity and a lack of expressed interest. The patch is still here for anyone that wants this functionality, but will likely never be committed. Thanks again, Vova.