fae icon indicating copy to clipboard operation
fae copied to clipboard

fae_association not compatible with simple_form's include_blank

Open Spone opened this issue 9 years ago • 7 comments

Hello,

I have a association pulldown which is optional. I passed the include_blank: true option to the helper, but I still have no way of "deselecting" a value.

Model:

class PlanningDate < ApplicationRecord
  # ...
  belongs_to :spot, required: false
  # ...
end

Form:

fae_association f, :spot, include_blank: true

I see that you use Chosen for these inputs. They have a specific option for this: allow_single_deselect: true

Could you add this option when include_blank: true is passed?

Spone avatar Aug 23 '17 10:08 Spone

Hi @Spone,

If you pass in a string to include_blank, you will be able to select that option.

Try: fae_association f, :spot, include_blank: 'Select One'

Hope that helps!

LeChin avatar Aug 23 '17 16:08 LeChin

Nice one, but now I have twice "Select One" when I create a new record.

Spone avatar Aug 23 '17 17:08 Spone

Ah! You're right, we are looking into a fix for this, thank you.

LeChin avatar Aug 23 '17 17:08 LeChin

@Spone it looks like you can use prompt: 'select one' and it won't generate a duplicate. @jamesmk do you still want to fix include_blank or should we just suggest using prompt in the documentation?

andrewdang17 avatar Sep 11 '17 23:09 andrewdang17

@Spone Fae uses the prompt option to add "Select One" by default which is the method to deselect an option. Is that not happening for you? You can override this message by passing in a custom prompt as @andrewdang17 suggested.

thanks

jamesmk avatar Sep 21 '17 07:09 jamesmk

The "Select One" item is displayed when I'm creating a record:

new

but it disappears when I'm editing it, so I can no longer unselect:

edit

Spone avatar Sep 25 '17 19:09 Spone

:+1: @andrewdang17

Spone avatar Nov 08 '17 21:11 Spone