except on
# avo-2
f
👋 I'm stuck on this - I'm trying to use
except_on
, but it is throwing a NoMethodError:
Copy code
field :last_verified_at, as: :date_time, except_on: [:create]
Error:
Copy code
NoMethodError: undefined method `show_on_create=' for #<Avo::Fields::DateTimeField:0x0000000118de2588 @show_on_index=true, @show_on_show=true, @show_on_new=true, @show_on_edit=true, @id=:last_verified_at, @name=nil, @translation_key=nil, @block=nil, @required=nil, @readonly=false, @disabled=false, @sortable=false, @nullable=false, @null_values=[nil, ""], @format_using=nil, @placeholder=nil, @help=nil, @default=nil, @visible=nil, @as_label=false, @as_avatar=false, @as_description=false, @index_text_align=:left, @html=nil, @view=nil, @value=nil, @stacked=nil, @resource=nil, @args={:as=>:date_time, :except_on=>[:create]}, @computable=true, @computed=false, @computed_value=nil>
Anyone know if I'm doing something stupid here?
l
Hi @fancy-crowd-87619 , there is no such thing like "doing something stupid" Which version are you using?
f
Thanks! 2.31
I just discovered that I can use `except_on: [:new] `and it does not throw an error. However, it does not work (the field still shows up!)
l
Using
:new
is what i was going to suggest you
Where it's showing up? It should show up only on the creation view of that resource
f
Interesting.
except_on
seems to do nothing for me (field still shows up on all views, including
new
). However,
hide_on
totally works.
This unblocks me cause I can just use
hide_on
with
new
, thank you!
> you may use the visibility helpers hide_on, show_on, only_on, and except_on methods. Available options for these methods are: :create, :edit, :index, :show, :forms
l
Actually I was wondering the same thing about the docs, I'll investigate it and fix it About the
except_on
doing nothing, I'm not sure why is that happening, im testing it locally and seems to be working
actually I just noticed a scenario where is not working for me too, there is possibly a bug somewhere
f
You rock!!
Interesting, let me know if I can provide more info about my specific scenario if that would be helpful. I'm not doing anything advanced (in my opinion).
l
I was able to reproduce it already, I'm figuring out whats going on and try to fix it, please use the
hide_on
option for now
Actually the
except_on
logic was inverted and the docs was wrongly referring to
:create
instead
:new
https://github.com/avo-hq/avo/pull/1927 https://github.com/avo-hq/avodocs/pull/95 There are two open PRs that fix both problems, thanks for reporting this!