7 Replies Latest reply on Dec 7, 2012 4:34 AM by beverly

    Making CWP forms dynamic (based on FMP layouts) a bit like IWP

    Malcolm

      The appeal of IWP is that you generate a layout in FMP and you publish that to the web. It's not without some effort and there are limitations but it works. It has occurred to me that Filemaker's API provides the means to do something similar using CWP. I am curious to know if anyone has used CWP to query the layout and dynamically create web forms from the objects that it finds there. If so, how effective is this method? Does the appeal of having the CWP form auto-generate pay-off or does it have drawbacks?

       

      The pipe-dream I'm having is a multi-page web form. In FMP a layout would represent a page on the web. Adding fields to the web forms would be as simple as putting them into the correct sequence and applying value list?

       

      I'd love to get feedback from anyone who has used CWP in this way.

       

      Malcolm

        • 1. Re: Making CWP forms dynamic (based on FMP layouts) a bit like IWP
          LyndsayHowarth

          Hi Malcolm,

           

          I've just done something similar for JSON imports where the field names and the number of them are unknown.

           

          There are some examples I have of this kind of generated code that I think was a rework of something the Assistant spat out in about v9 or maybe 8.5. I also learnt Lasso code originally like that.

           

          The problems as I see it is that you are constantly keeping your head full of loops and variables that keep changing and you end up needing more layouts than is reasonable because EVERYTHING ends up on your form page whether you want it there or not unless you customise. If you do customise you end up using code like "get the 5th item in the array and get the 4th valuelist... blah". Select and radio and textarea become variables that are deployed and populated conditionally.

           

          I'm certainly not trying to discourage you. If you did it well you could save so much time for new projects. My experiences have always brought me back to the custom pages where my code is meaningful. That's not to say that there won't be some elements of it in my code as includes.

           

          Plan well, good sir!

           

          - Lyndsay

          1 of 1 people found this helpful
          • 2. Re: Making CWP forms dynamic (based on FMP layouts) a bit like IWP
            Malcolm

            The problems as I see it is that you are constantly keeping your head full of loops and variables that keep changing and you end up needing more layouts than is reasonable because EVERYTHING ends up on your form page whether you want it there or not unless you customise.

             

            I'd thought about that. It is possible to send input to one layout and ask for output that is returned from a different layout. That answers some of those issues.

             

            If you do customise you end up using code like "get the 5th item in the array and get the 4th valuelist... blah". Select and radio and textarea become variables that are deployed and populated conditionally.

             

            I take the point about customising. I had hoped that CWP respected the layout or tab order of the fields. The idea is to use layouts to "build" the form. Let PHP walk through the list of fields and get all their attributes, including the value list assigned to the field, and generate the appropriate HTML code.

             

            I'm certainly not trying to discourage you. If you did it well you could save so much time for new projects.

             

            A client asked if they would be able to modify the web forms that we are creating. I've said that it will be theirs to break as soon as we sign off but it made me wonder if there was a possibility that they could do so by simply adding fields to a layout.

             

            I can see why Filemaker wouldn't bother to provide this to CWP, even if they have tried it. At present I'm only interested in a single column of objects. As soon as they hinted at something like this the first request would be for the API to return positions and dimensions so that fields could be set side by side, then colours, font formatting, other layout objects, button scripts, etc. Suddenly it sounds a lot like IWP.

             

            My experiences have always brought me back to the custom pages where my code is meaningful. That's not to say that there won't be some elements of it in my code as includes.

             

            Interesting. It's that sort of experience that I was hoping to discover. I'll begin by building a function that generates a form input from a specified field on the layout. That will be useful to me in any project and it won't be a waste of time. (At that point, building the whole page is a call to getFields and a loop that points at the new function)

             

            thanks

            Malcolm

            • 3. Re: Making CWP forms dynamic (based on FMP layouts) a bit like IWP
              steve.winter

              Hi Malcolm

               

              Over time I have developed something similar to what you're talking about - it's not CWP following a layout, but it's certainly a significant amount of form configuration undertaken in FMP, then minimal custom code required for each page in a client site.

               

              In FM I have two tables, fields and field sets. Field sets holds information like the layout in FM that data comes from, and that it gets posted back to, the URL to post to, the title for the form etc. There is then a portal which shows records from the fields table. That fields table holds things like field name, onscreen title, field type (e.g. text, select, radio, textArea, date, futureDate, content, header etc, many of which are standard form elements, others of which are constructions on that which my PHP interprets into a mix of HTML and JavaScript) value list, if the field is read only, disabled, required and importantly display order etc.

               

              A second table holds the webpage content for a particular URL - this text includes the page and browser titles, plus the content to go on the page.

               

              A third table holds error and customer-facing messages and alert text.

               

              Then, to create a new form on a web site, on the PHP side a config file gets told the URL which the page will have - from there the PHP takes over and looks to see if there's any content for the page, and any forms for the page, and then generates the HTML for the page based on that…

               

              Because this solution grew through earlier version of FM where the API (or FX) were comparatively slow, I don't read this config directly from the DB on each page load. Instead there is 'publishing' code which exports the configuration data into three php files, which are then used to construct the page.

               

              This way I can build a solution, relatively quickly, and clients can manipulate the fields which appear in any given form with ease - so long as the field they want in the form is on the referenced layout, they can add or modify the form definition in FM and republish the config file at any time thereby updating the site.

               

              As far as value lists go, I have a single layout in the DB onto which I place a single global field multiple times, with each value list which is used in the fields definition attached to it. At page load time my PHP code then uses getValueListTwoFields to get all of the value lists off that layout and cache them in a session variable (so it only goes there once per visitor session). That way I can then reference them by name in the fields definition and the PHP code which describes select/radio/checkbox knows how to source the value list from that session variable to display in a form.

               

              Hope this makes sense and is of some help to you… give me shout if you're interested in further details.

               

              Cheers

              Steve

               

              Steve Winter

              Matatiro Solutions Limited

              steve@matatirosolutions.co.uk

              p:  +44 23 8064 4181

              m: +44 77 7852 4776

              USA: +1 415 315 9912

              2a St. Mary's Road

              Bishopstoke SO50 6BP

               

              Registered in England and Wales: 6300320

              Registered Office: 44 Southchurch Road, Southend, SS1 2LZ

              VAT Registration Number: 916 8809 86

              IMPORTANT: This message is private and confidential. If you have received this message in error, please notify us and remove it from your system.

              • 4. Re: Making CWP forms dynamic (based on FMP layouts) a bit like IWP
                LyndsayHowarth

                Steve... sounds great. I felt a great deal of familiarity with some of your techniques and there were a couple that got me thinking.

                 

                I built a store in CDML (a lifetime ago) which I keep telling myself I'll redo in PHP. It worked in a similar fashion where all the variables which made up the web pages were field values. This included Host colours and images and everything... and of course the system stores multiple Hosts. I built the web interfaces for Store Owner, Store, and Member Accounts. I think it was not long after that completing it that they announced the demise of CDML... but it is still running today.

                 

                I have a solution which was begun in about v8 which has been built on similar principles for FMP and IWP access but it is only recently I have built the custom web pages for some of the modules. One of those is a store and only last week I opened a store for it's first commercial client as SAAS. I will be setting up a new 12 server soon and clients will be able to access the system with GO. It will also running my new web site with much more than just the store back-ended by FileMaker. I have built the pages to a template with includes which I can show or hide for modules according to DB values. Combined with CSS... the templates are redeployable anywhere.

                 

                There is one thiing for certain... the more I build the more I can reuse.

                 

                Sent from my iPad

                Lyndsay Howarth

                11th Hour Group Pty Ltd

                • 5. Re: Making CWP forms dynamic (based on FMP layouts) a bit like IWP
                  Malcolm

                  Over time I have developed something similar to what you're talking about - it's not CWP following a layout, but it's certainly a significant amount of form configuration undertaken in FMP, then minimal custom code required for each page in a client site.

                   

                   

                  In FM I have two tables, fields and field sets. Field sets holds information like the layout in FM that data comes from, and that it gets posted back to, the URL to post to, the title for the form etc. There is then a portal which shows records from the fields table. That fields table holds things like field name, onscreen title, field type (e.g. text, select, radio, textArea, date, futureDate, content, header etc, many of which are standard form elements, others of which are constructions on that which my PHP interprets into a mix of HTML and JavaScript) value list, if the field is read only, disabled, required and importantly display order etc

                   

                  Is this similar to the questionnaire example that Filemaker provides? I'm looking at it presently. The user defines questions, determines what sort of form input is required and provides data to be used as value lists. I've extended it to include section titles, sub-headers and information. I've been thinking about a whether a naming methodology could be used for layouts or whether it is simply easier to put all of this information into data where a knowledgable user would be able to edit. It sounds like you're following the latter method.

                   

                  Malcolm

                  • 6. Re: Making CWP forms dynamic (based on FMP layouts) a bit like IWP
                    steve.winter

                    Malcolm

                     

                    I'm following the later -  a knowledgeable user manages the form configuration.

                     

                    With clients who have been using this system for a while, they will often come to me and say 'I've created three new forms which need to go on the websites, the URLs are x, y, z. On form z there needs to be some custom JavaScript to do foo bah'. So basically they've already done the bulk of the work - I then add the URLs to the PHP config, add the custom JS, and it's done…

                     

                    From that point on, they can modify the form to look as they wish, and to have the fields/questions which they desire. Each element in the definition is made up of three components, a wrapper (either a

                    element or a

                    depending on the type of input, a label, and the element itself. Each of them can have CSS classes applied to them from within FM, and there are a lib ray of standard classes which give margins, padding and widths.

                     

                    It's also possible to add div wrappers in a form definition, and they can also have classes applied to them, for example to create a 'zebra stripe' type effect into a form, or to acts as a wrapper to contain multiple fields floated beside each other…

                     

                    HTH

                    Steve

                     

                    Steve Winter

                    Matatiro Solutions Limited

                    steve@matatirosolutions.co.uk

                    p:  +44 23 8064 4181

                    m: +44 77 7852 4776

                    USA: +1 415 315 9912

                    2a St. Mary's Road

                    Bishopstoke SO50 6BP

                     

                    Registered in England and Wales: 6300320

                    Registered Office: 44 Southchurch Road, Southend, SS1 2LZ

                    VAT Registration Number: 916 8809 86

                    IMPORTANT: This message is private and confidential. If you have received this message in error, please notify us and remove it from your system.

                    • 7. Re: Making CWP forms dynamic (based on FMP layouts) a bit like IWP
                      beverly

                      Very nice Steve! IWP uses JavaScript, data from what we might get out of Design functions (field position, bounds, labels, fonts, etc.) and CSS to create the pages. Recreating would take a bunch of work. It sounds like you did that work!

                       

                      Creating the 'configs' as sort of includes is a great technique. When I have elements on web pages that don't change often and can be exported (text) to become includes, I do just that. It certainly saves hitting the database each and every time. Reserve the hits for data that needs to be "up-to-the-minute".

                       

                      Bev