Announcement

Collapse
No announcement yet.

Filtering entities by related entity's properties

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #16
    "view": "Fields.Enum",
    "options": [ COPY OPTIONS FROM ACCOUNT ]

    Comment


    • #17
      So given that this works well, I think I'll look at making it automatic - so the code that creates ormMetadata.php would add every fieldtype that exists as a filter for an entity as a foreign field to any entity which has a relationship with it.

      That shouldn't be too tricky to figure out.

      Comment


      • #18
        Because doing this manually is a bit of a pain.

        Comment


        • #19
          Originally posted by yurikuzn View Post
          "view": "Fields.Enum",
          "options": [ COPY OPTIONS FROM ACCOUNT ]

          I'm looking at Model::getfieldType().

          Can you access one models' field defs from another model.

          eg

          PHP Code:
          getFieldType: function (field) {
                      if ((
          'defs' in this) && ('fields' in this.defs) && (field in this.defs.fields)) {
                          if (
          this.defs.fields[field].type === 'foreign') {
                              
          model GET_MODEL_FROM_NAME(this.defs.fields[field].link);
                              return 
          model.defs.fields[field].type;
                          }
                          else return 
          this.defs.fields[field].type || null;
                      }
                      return 
          null;
                  }, 

          Comment


          • #20
            More thinking required, but am getting somewhere thanks

            Comment


            • #21
              So I was looking at this again last night.

              During a rebuild, after the Unifier stage, I will scan the metadata and create the foreign fields. I will also modify the clientLayouts so that the filters are available.

              But the problem is in the client code, where I need to get the properties of the foreign fields - ie the default option, min/max, enumerations, etc. Do you have a suggestion on how to do that?

              Comment


              • #22
                You don't need the most of params from foreign field. Only "options".

                Comment


                • #23
                  Yes, but is there a cleaner way to do this, other than scraping through the metadata structure?

                  Comment


                  • #24
                    Don't think so.

                    Comment


                    • #25
                      Hi Im revisiting this, as I really need the functionality.

                      I can get the options for the foreign field from getMetadata() in side views/search/filter.js however how & where do I apply these and to what object?

                      Comment


                      • #26
                        Has the field type foreign for any field except name and id been removed? I can't get this working and can't find any implementation in the code.

                        Comment

                        Working...
                        X