https://avo.cool logo
Join Discord
Powered by
# fields
  • How hard could it be to update the dynamic filt...
    m

    miniature-optician-85831

    04/02/2024, 10:20 PM
    Thread automatically created by YorSant#83 in #1141725718364045394
    s
    l
    • 3
    • 2
  • I just added some required fields to an action,...
    m

    miniature-optician-85831

    04/06/2024, 9:54 PM
    Thread automatically created by YorSant#83 in #1141725718364045394
    l
    s
    +2
    • 5
    • 16
  • Hy folks, I'm using Avo Advanced and I would li...
    m

    miniature-optician-85831

    04/12/2024, 1:39 PM
    Thread automatically created by Dorian.Lupu in #1141725718364045394
    v
    l
    • 3
    • 20
  • Hi guys, I'm having the following issue. It sou...
    s

    swift-businessperson-84139

    04/25/2024, 3:53 AM
    Hi guys, I'm having the following issue. It sounds like a bug to me.
    Copy code
    ruby
    field(:name, as: :text, name: 'Full Name', link_to_record: true, filterable: true, sortable: true)
    field(
      :email,
      as: :text,
      protocol: :mailto,
      filterable: true,
      sortable: true,
      visible: lambda {
        current_user.management? || current_user.board_member? || current_user == resource.record.user
      }
    )
    field(
      :phone,
      as: :text,
      protocol: :tel,
      filterable: true,
      sortable: true,
      visible: lambda {
        current_user.management? || current_user.board_member? || current_user == resource.record.user
      }
    )
    field(
      :tags,
      as: :tags,
      filterable: true,
      sortable: true,
      help: 'Press comma to enter more than one tag. Tags with multiple words are allowed.'
    )
    The table is broken with the above fields; please look at the image. https://cdn.discordapp.com/attachments/1141725718364045394/1232902291657461871/Screenshot_2024-04-24_at_11.49.09_PM.png?ex=662b253c&is=6629d3bc&hm=aed39532b412e0fb47926f7edf0fa7f523e1712974f450d5d51ddb1f00faa6c6&
    m
    l
    • 3
    • 15
  • hi guys - on a tag-field. is it possible enfore...
    m

    modern-ambulance-83380

    04/25/2024, 2:20 PM
    hi guys - on a tag-field. is it possible enfore suggestions via
    enfore_suggestions: true
    without pre-filling them when creating a new record? i have a lot of options to choose from but the user should only select a few. with the current setup, the user has to delete all of the suggestions first before he can select the tags wanted. thats my field:
    Copy code
    ruby
    field :disciplines,
              as: :tags,
              delimiters: [","],
              suggestions: -> { record&.disciplines&.present? ? record&.disciplines : [] },
              enforce_suggestions: true
    m
    l
    • 3
    • 7
  • is there a way to pass instance specific option...
    f

    future-garden-51299

    04/26/2024, 4:05 PM
    is there a way to pass instance specific options to a field? specifically, I'd like to conditionally pass the correct
    geometry
    argument to the
    area
    field type based on whether the geojson is multipolygon or polygon. It appears that field specific options are static...
    m
    l
    • 3
    • 3
  • Is there a way to get an audio file field to sh...
    p

    purple-park-97233

    04/28/2024, 5:49 PM
    Is there a way to get an audio file field to show the media player on index view? My field looks like:
    field :soundtrack1, as: :file, is_image: false, display_filename: false
    m
    l
    • 3
    • 4
  • During edit, trix fields lose captions on image...
    c

    calm-gold-48525

    05/02/2024, 1:02 AM
    During edit, trix fields lose captions on image attachments. Add an attachment to a trix field, enter a caption, and then save. Then edit the record. The caption is rendered as part of the text. If you save the record, the text is saved as part of the text body, not the caption. Anybody else see that? I can add a github issue, but I wanted to check first to see if anybody knows a workaround.
    m
    l
    • 3
    • 5
  • Hello. Are there any updates on the money field...
    s

    swift-businessperson-84139

    05/17/2024, 6:43 PM
    Hello. Are there any updates on the money field documentation? I'm trying it, but I haven't made it work. (I may be doing something wrong)
    m
    l
    • 3
    • 18
  • Is there an easy way to add a dropdown with a f...
    s

    swift-businessperson-84139

    05/18/2024, 10:49 PM
    Is there an easy way to add a dropdown with a few icons? I'm adding categories with a name, icon, and color. Something like:
    Copy code
    ruby
    def fields
      field(:name, as: :text)
      field(:icon, as: :select, options: -> { helpers.icons_for_select })
      field(:color, as: :text) # color picker???
    end
    I wonder if there is a way to use
    icon: "heroicons/outline/eye"
    with a list of icons, as Avo does in a few places (maybe color too). Has anyone tried it before? Thanks in advance.
    m
    l
    • 3
    • 3
  • I'm working on building an action where I want ...
    r

    rough-student-26326

    05/25/2024, 7:07 PM
    I'm working on building an action where I want to have a field where I can select a model. I've only been able to use a select field so far, but this isn't practical for models that have a lot of records. Is it possible to use something like
    has_one
    or a
    belongs_to
    field for something like this?
    m
    • 2
    • 1
  • Hi, I have a field that is disabled by default....
    p

    purple-park-97233

    06/25/2024, 1:36 PM
    Hi, I have a field that is disabled by default. On change of a select filed I wish to enable it and about 4 other fields. I'm struggling to get this to work. I'd like to use the disable pre made action of resource-edit but unsure how to use those from another controller.
    Copy code
    import { Controller } from '@hotwired/stimulus'
    
    export default class extends Controller {
      static values = {
        view: String,
      }
    
      static targets = ["typeSelectInput", "marriagedateDateWrapper", "marriagedateDateInput"];
    
      async connect() {
        console.log('view ->', this.viewValue)
      }
    
      typeChanged() {
        console.log('type was changed');
    
        let value = this.typeSelectInputTarget.value;
    
        if (value == "Spouse") {
            console.log('Selected SPOUSE');
    
            this.marriagedateDateInputTarget. // Activate field here
        }
      }
    }
    m
    l
    • 3
    • 7
  • Why title field form hidden only on Chrome brow...
    w

    wooden-musician-16187

    07/03/2024, 8:38 AM
    Why title field form hidden only on Chrome browser Avo version: 3.10.0 https://cdn.discordapp.com/attachments/1141725718364045394/1257978859320508486/image.png?ex=66865f9c&is=66850e1c&hm=fd94a994d493411a2b01d113588049f1fd5250ffa8a41502af0a467edea151e6&
    m
    l
    • 3
    • 4
  • Is there a way to access the selected resource_...
    p

    purple-analyst-91381

    07/03/2024, 1:55 PM
    Is there a way to access the selected resource_ids within the fields of an action? I'm wanting to show a select that is filtered based on what the user has checked on an index action. On the show action it works great I can use a belongs_to with an attached scope which gives me access to the parent record to filter the dropdown. I've been trying for hours to find a way but I've had no luck, thank you!
    m
    l
    • 3
    • 8
  • I have a field which is a reference to another ...
    b

    broad-helmet-78129

    07/03/2024, 8:07 PM
    I have a field which is a reference to another resource with
    :belongs_to
    , but I'd like to display a field that is more meaningful than the object id (namely the
    :description
    field of the associated resource)
    m
    l
    l
    • 4
    • 5
  • Is there a way to make this external_image fiel...
    p

    purple-park-97233

    08/18/2024, 6:36 PM
    Is there a way to make this external_image field link to a resource path? field :photo, as: :external_image, name: "Main Photo" do record.photo.url end
    m
    l
    • 3
    • 8
  • When using `attach_fields`, is there anything s...
    p

    purple-park-97233

    08/19/2024, 9:00 PM
    When using
    attach_fields
    , is there anything special I need to add to my model or controller somewhere? I have the following "Company" field:
    Copy code
    tab "Companies" do
                    field :companies, as: :has_many, through: :coaster_companyables,
                        attach_scope: -> { query.order(name: :asc) },
                        searchable: true,
                        show_on: :edit,
                        linkable: true,
                        attach_fields: -> {
                            field :role, as: :text
                        }
                    # field :companyables, as: :has_many
                end
    And when i try to attach a company and type a Role in, I just get Avo stating "Failed to attach Company". No errors in the log, just this line:
    Copy code
    rocessing by Avo::AssociationsController#create as TURBO_STREAM
    20:58:39 web.1    |   Parameters: {"authenticity_token"=>"[FILTERED]", "fields"=>{"related_id"=>"intamin-amusements", "role"=>"trains"}, "button"=>"", "view"=>"show", "resource_name"=>"attractions", "id"=>"this-one-at-this-place", "related_name"=>"companies"}
    Just wondered if i'm missing something before I spin up a demo app.
    m
    l
    • 3
    • 48
  • Hey all. So it looks like on an edit form with ...
    b

    boundless-printer-62821

    08/20/2024, 3:58 PM
    Hey all. So it looks like on an edit form with a belongs_to, the select box of possible associations can be massive if there is a huge number of possible records that can be associatied (I guess just showing all possible records of the given type?). Is there a lazily loaded/search powered alternative?
    m
    l
    • 3
    • 7
  • Hi all, This is more of a "Is there an option...
    p

    purple-park-97233

    09/14/2024, 10:33 AM
    Hi all, This is more of a "Is there an option I haven't thought of approach" type of question: Ok, So I have a Company model which is connected to my Attraction and Venue models via a polymorphic has_many : through association. The join model is called Companyable and is used to store the Role that a Company had in a particular Attraction or Venue. This is all great and works in Avo amazingly! Ok, here's where i'm unsure what approach to take. On the Attraction side, I wish to store the Model and SubModel of each one. Models and SubModels are only necessary for SOME companies NOT all. Some Attractions I only have a Model and no SubModel. I'm thinking that I can keep my current associations as they are, but create new Rails Models for Model and SubModel. Then on my edit page I can use the Avo Stimulus functionality to be able to choose a Company, Then a Model, and then a SubModel. In this case I need to find out how to only submit the deepest select box value (eg, don;t submit SubModel if no SubModel was chosen). This sounds like it should work fine, BUT we COULD get to a scenario where an Attraction has a Model and SubModel selected for a Company that isn't associated. This obviously does not make any sense. Ideally i'd like to be able to have the dependent selects ONLY show Companies in the first of the three selects (Companies, Models, SubModels), that have been associated. This is fine if the Model/SubModels are being associated after the Attraction exists, but if i'm creating a new Attraction, due to not being able to attach the Company at creation time, I can't do this. One thing I COULD do is to have some sort of check on the Index view that highlights or tags all records where the Model/SubModel Company does not match one of the regular attached Companies and then i can fix it. I'm trying to build this with Avo in mind. Just happy to hear some other people's thoughts on approaches I could take.
    m
    l
    • 3
    • 12
  • Hello, Just a follow on question to the above....
    p

    purple-park-97233

    10/04/2024, 4:07 PM
    Hello, Just a follow on question to the above. I pretty much have come up with a solution to the above, just now trying to implement a decent UI. What I want is a set of 3 dependent Select boxes. Company => Model => Submodel. I've been tearing my hair out trying to get an example of this working by following the example in this guide: https://docs.avohq.io/3.0/stimulus-integration.html#custom-stimulus-controllers That's great and all but due to some differences in what i'm aiming for i'm really struggling. My associations look like: Companyable: belongs_to :company belongs_to :companyable, polymorphic: true belongs_to :model, optional: true belongs_to :submodel, optional: true Company: has_many :companyables has_many :models Model: belongs_to :company has_many :submodels Submodel: belongs_to :model My Company field on the Companyable Resource looks like: field :company, as: :belongs_to, html: { edit: { input: { data: { companyable_resource_target: "companyFieldInput", # Make the input a target action: "input->companyable-resource#onCompanyChange" # Add an action on change } } } } The Model field on the Companyable Resource looks like: field :model, as: :belongs_to, html: { edit: { input: { data: { companyable_resource_target: "modelFieldInput" # Make the input a target } } } } Just wondering if someone had an example where the fields were
    belongs_to
    and not `select`s. I'd appreciate a bit of help with getting this up and running and i've been scrabbling for days on this. Sigh
    m
    l
    • 3
    • 24
  • Are fields with a `:has_one` relationship suppo...
    m

    mammoth-guitar-49791

    10/08/2024, 10:22 AM
    Are fields with a
    :has_one
    relationship suppose to trigger scope? In the documentation has_many relationships are not suppose to trigger a scope through association, only index. https://docs.avohq.io/3.0/authorization.html#associations shouldn't the behavior be the same for has_one? https://cdn.discordapp.com/attachments/1141725718364045394/1293156682368553021/image.png?ex=67065982&is=67050802&hm=d5a4c19377850d3d5062d60621351eb65357d62470933929e67ef0029a10374e&
    m
    l
    • 3
    • 15
  • Hey everyone, is there a way to filter out spec...
    h

    helpful-waitress-4127

    12/16/2024, 6:53 PM
    Hey everyone, is there a way to filter out specific values to display in the belongs_to select? I would like to display fields of study that are related to selected macro major and not all of them also ideally have field of study greyed out until macro major is selected
    Copy code
    class Avo::Resources::Listing < Avo::BaseResource
      # self.includes = []
      # self.attachments = []
      self.search = {
        query: -> { query.ransack(name_cont: params[:q], description_cont: params[:q], m: "or").result(distinct: false) }
      }
      self.title = :description
    
      def fields
        field :id, as: :id
        field :name, as: :text
        field :occ_macro_major, as: :belongs_to, searchable: true
        field :occ_field_of_study, as: :belongs_to, searchable: true
      end
    end
    Copy code
    class OccMacroMajor < ApplicationRecord
      has_many :occ_field_of_studies, inverse_of: :occ_macro_major, dependent: :destroy
      has_many :listings, inverse_of: :occ_macro_major
    end
    Copy code
    class OccFieldOfStudy < ApplicationRecord
      belongs_to :occ_macro_major, inverse_of: :occ_field_of_studies
      has_many :listings, inverse_of: :occ_field_of_study
    end
    m
    l
    • 3
    • 13
  • Any way to use tags that have commas in them?
    a

    able-needle-51274

    12/17/2024, 8:36 PM
    Any way to use tags that have commas in them?
    m
    l
    l
    • 4
    • 6
  • https://docs.avohq.io/3.0/stimulus-integration....
    h

    helpful-waitress-4127

    12/18/2024, 10:39 PM
    https://docs.avohq.io/3.0/stimulus-integration.html#pre-made-stimulus-methods is there a way to toggle visibility depending on field value (true or false) instead of on click event? in the provided example it does not matter what value is when editing the resource, visibility is updated on checkbox click
    m
    l
    • 3
    • 5
  • https://docs.avohq.io/3.0/fields/tags.html#opti...
    m

    miniature-optician-85831

    01/14/2025, 10:20 PM
    Thread automatically created by John Ngo in #1141725718364045394
  • https://docs.avohq.io/3.0/custom-errors.html#in...
    m

    miniature-optician-85831

    01/14/2025, 10:52 PM
    Thread automatically created by John Ngo in #1141725718364045394
    h
    • 2
    • 2
  • Hello Guys, anyone having trouble to setup defa...
    q

    quaint-pencil-2979

    02/07/2025, 1:36 PM
    Hello Guys, anyone having trouble to setup default value in fields?
    Copy code
    def fields
        field :id, as: :id
        field :name, as: :text, name: "Nome", required: true
        field :email, as: :text, required: true
        field :password, as: :password, only: [:new, :edit]
        field :role, as: :select, enum: ::User.roles, name: "Acesso a plataforma", default: "super_admin", readonly: true
      end
    m
    l
    • 3
    • 10
  • I haven't thoroughly investigated yet, but it s...
    s

    straight-pager-31449

    02/17/2025, 8:14 AM
    I haven't thoroughly investigated yet, but it seems that the limit restriction on has_many may no longer work. avo: 3.17.3 rails: 8.0.1
    Copy code
    field :foo, as: :has_many, scope: -> {
          query.limit(3) # limit does not work
        }
    Copy code
    has_many :foo, -> { limit 3 }  # limit does not work
    m
    l
    • 3
    • 10
  • Has anybody built a rating field? Like 4 out of...
    c

    calm-gold-48525

    03/15/2025, 1:35 AM
    Has anybody built a rating field? Like 4 out of 5 stars (or thumbs, moneybags, skulls, etc)?
    m
    l
    • 3
    • 2
  • Hi, I'm trying to pass a list of id's through...
    p

    purple-park-97233

    03/25/2025, 8:44 PM
    Hi, I'm trying to pass a list of id's through to an action like so:
    Copy code
    action Avo::Actions::MakeMainPhotoFor,
                arguments: -> do
                    {
                        attractions: record.attractions.pluck(:id)
                    }
                end
    but in the fields method I try to output that and I get the id of a record from a totally different class. Any ideas?
    m
    • 2
    • 2