1

I am using CFwheels for a site that I am creating and need to use a nested view. However, when I submit the form on the popup view, the component doesn't seem to work.

Below is some test code that I am using (when I use the view in the popup as an individual page everything works fine).

Is there a specific method to make something like this happen or is something like this unsupported in CFWheels?

global.cfm - Parent View

  <a href="##createClient" role="button" class="btn btn-success" data-toggle="modal">Add New Client</a>            



 <div id="createClient" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <cfinclude template="createClient.cfm">
 </div>

createClient.cfm - nested view (popup)

<form method="post" action="createClient">
<input type="hidden" name="isPost" value="1" />


        <table>
        <div class="modal-body">
            <tr>
                <td>Client Brand Name:</td>
                <td><input type="text" name="ClientBrandName" value="" required></td>
            </tr>

            <tr>
                <td>Survey Referral:</td>
                <td><input type="text" name="surveyReference" value="" required/></td>
            </tr>

Controller of nested view

<cffunction name="createClient">        
    <cfif isDefined('form.isPost')>
        <cfscript>
         application.someComponent.someFunction(
            CBname = params.clientbrandname,
            sRef= params.sreferralid,
            sRefname = params.surveyreference
         );
        </cfscript>
    </cfif>
</cffunction>
Leigh
  • 28,765
  • 10
  • 55
  • 103
Geo
  • 3,160
  • 6
  • 41
  • 82
  • Just as an aside about general CFML, why do you put that function call in a CFscript block rather than just a ``? – Adam Cameron Jan 04 '14 at 19:21
  • @AdamCameron no particular reason. These are practices that I picked up around my workplace based on what they have been using for the last 10 years. – Geo Jan 05 '14 at 01:38

1 Answers1

0

I'm not directly answering your question, but you're not approaching this in a very 'wheels-y' way.

firstly, all cfwheels form + url params are pushed into the params scope, so generally, we'd be doing structkeyexists(params, "isPost") (or some such) for a start. (that's not to say that the form scope is inaccessible though).

secondly, you might find includePartial() more useful than cfinclude, as you can pass named arguments through.

Ajax/Modal calls are supported in wheels, but I'd wager you're accidentally submitting to the wrong URL; you'd need to strip the layout too.

Have a look at https://github.com/neokoenig/RoomBooking - there's several examples of bootstrap modal windows which may help.

Neokoenig
  • 1,102
  • 7
  • 16
  • Thanks for the suggestions. I think I found what the issue is though. The partial is on a page called 'global' so when I change the function inside the the component from `createClient` to `global` the form is passing through just fine. This approach won't work though because on the global page I am going to have about 10 partials so I decided to submit each one with an ajax call instead. – Geo Jan 05 '14 at 01:43