-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to add multiple images #3
Comments
Hardest part of this will be the cell displaying the images... having the ability to delete the images and add more, etc. Any ideas on that? |
With the current code, I think it could be done with a Something like {
title: 'Images',
name: :picture,
type: :image,
on_add: -> {
@current_images += 1
if @current_images == 12
a_method_to_get_the_section.options = [:delete]
else
a_method_to_get_the_section.options = [:insert, :delete]
end
},
on_remove: -> {
# same stuff
}
} Ideally, this could be done internally. I really like the |
Or required: [2, 12] ? |
I figured I'd piggyback on the required statement. As far as the array, I much prefer a more definitive declaration. |
And I'm just spitballing here :)
|
Using this code : def form_data
[
{
title: 'Images',
name: :images,
options: [:insert, :delete],
cells: [
{
type: :image,
name: :image,
title: 'Image',
on_add: -> {
@current_images ||= 1
@current_images += 1
if @current_images >= 4
section = section_with_tag(:images)
section.options = [:delete]
end
},
on_remove: -> {
@current_images -= 1
if @current_images < 4
section = section_with_tag(:images)
section.options = [:insert, :delete]
end
}
}
]
}
]
end I had to refactor a lot of code... now, I just need to find a good name for this required number |
haha. AWESOME! I'll give it a try and let you know how it goes. |
Just tried it and it works great! Only change I'm going to try and make at some point is that i want them to add one image and then after they select the image another row pops up. The delete button shouldn't show up till they've actually selected an image. Essentially, I want them to select one image at a time, after selecting, another row shows up. |
To do this kind of thing, it will require some hacking of XLForm, but it will be awesome |
This one could be hard but I'm going to need it for an upcoming project :)
Perhaps something like this:
The text was updated successfully, but these errors were encountered: