Hi Gareth,

The Reactor part to this is easy, open up your /model/data/Metadata folder
and add extra metadata to the table column to describe what type of form
field to use. The columns are stored in an array, refer to
reactor/project/your_project/Metadata/yourTableMetaData.cfc for the correct
position (it should be the ordinal position in the table).

heres an example, i want date columns rendered with a "calendar" field type

/model/data/Metadata/NewsMetaData.cfc
<cfcomponent hint="I am the database agnostic custom Metadata object for the
News object.  I am generated, but not overwritten if I exist.  You are safe
to edit me."
    extends="reactor.project.mg2test.Metadata.NewsMetadata">
    <!--- Place custom code here, it will not be overwritten --->

   <!--- fields[4] is the `Date` column --->
    <cfset variables.metadata.fields[4]["fieldtype"] = "Calendar" />

</cfcomponent>

Reactor will now return this extra property whenever metadata for the News
table is required.

Getting Model-Glue to use this is a little trickier, and requires a little
hacking of the framework files.  In ModelGue/unity/orm/ReactorAdapter.cfc
you'll need to pull your new property and insert it into the MG's metadata
format.

*After this block (about line 117)*

    <!--- Add simple fields --->
    <cfloop from="1" to="#arrayLen(fields)#" index="i">
        <cfset md[fields[i].alias] = duplicate(fields[i]) />
        <cfset md[fields[i].alias].sourceObject = "" />
        <cfset md[fields[i].alias].sourceColumn = "" />
        <cfset md[fields[i].alias].sourceKey = "" />
        <cfset md[fields[i].alias].relationship = false />
        <cfset md[fields[i].alias].linkingRelationship = false />
        <cfset md[fields[i].alias].pluralRelationship = false />

*Add*
        <cfif not StructKeyExists(md[fields[i].alias], "fieldtype")>
            <cfset md[fields[i].alias].fieldtype = "" />
        </cfif>

Then at line 261, where the properties are looped over, add your new field
to the list

                    <cfloop
list="*fieldtype*,nullable,cfdatatype,primarykey,sourcecolumn,pluralrelationship,relationship,sourceobject,name,default,sourcekey,length,alias,label,comment"
index="j">

You'll now be able to access the fieldtype property in your xsl files

<xsl:if test="fieldtype = 'Calendar'">
  &lt;cfcalendar ... /&gt;
</xsl:if>

I've never used this, but in my brief testing it seems to work fine.  I
can't think of a way to do this without altering ReactorAdpater.cfc, if i've
missed something obvious i'm sure others will chime in.

Cheers, Chris

2008/9/23 Gareth Cole <[EMAIL PROTECTED]>

>  Hi,
>
>
>
> I'm not sure if this question is better suited to the reactor mailing list,
> but here goes:
>
>
>
> I'm using Model glue 2 with reactor and I've been playing about with
> customising the scaffolding xsl files. I've found this really powerful,
> and a lot easier than I thought. With a few changes to the xsl, I've
> really reduced the time I spend customising generated forms.
>
>
>
> The xsl generates different types of form input depending on the DB field
> type. What I'd like to do, is add an extra setting (probably in the reactor
> config or metadata files), so that I can over-write the field type
> generated, and introduce my own custom inputs.
>
>
>
> As an example, if database column 'comments' is a long text field, then by
> default the xsl renders this as a <textarea>. If I want this to be a
> wysiwyg editor, I need to edit it manually in the form. Ideally, I would
> like to specify that the 'comments' column should render as a wysiwyg in a
> config file somewhere, and then change the xsl to render it as a 
> wysiwygautomatically.
>
>
>
> Does anyone know if this is possible, and how I would go about it?
>
>
>
> Thanks,
>
>
>
> Gareth
>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "model-glue" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/model-glue?hl=en

For more about Model-Glue, check http://www.model-glue.com .
-~----------~----~----~----~------~----~------~--~---

Reply via email to