0 Replies Latest reply on Mar 5, 2014 9:32 AM by gwarmonger

    CFwheels..update by ID

    gwarmonger

      I've recently started using CFwheels. I am trying to update a database item by ID.

       

      Usually what I would do is have a hidden form field that passes an ID number in the value. Then I would run a query something like SET WHERE ID=#ID#.

       

      First problem...I am not sure how to set the value on the input control...I have -

       

      #checkBox(objectName="reqequip", property="#serial#", defaultValue="#serial#", label="")#
       #hiddenField(objectName="reqequip", property="#serial#", label="")#
      

       

      Which prints out this below. I thought property argument is supposed to define value but it is not. And also I do not even know where the 3rd item is coming from as I only have two form fields.

       

      <input id="reqequip-testatawetg" type="checkbox" value="1" name="reqequip[testatawetg]" defaultvalue="testatawetg"> <input id="reqequip-testatawetg-checkbox" type="hidden" value="0" name="reqequip[testatawetg]($checkbox)">
      
       <input id="reqequip-testatawetg" type="hidden" value="" name="reqequip[testatawetg]" label="">
      
      
      

       

      My controller is -

       

      <cffunction name="reqequip">
              <cfset reqequip = model("equips").new()>
              <cfset reqequip.update(status="Pending", properties=params.reqequip)>
          </cffunction>
      
      

       

      The whole form is in a loop...so each row has a different id...I want to select one row and then update the STATUS column for that row when I submit.. ..here is the whole form ---

      <cfoutput>

          #startFormTag(action="reqequip", id="reqequip")#

           #dateSelect(objectName="reqequip", property="startdate", order="day,month,year")#

            #dateSelect(objectName="reqequip", property="enddate", order="day,month,year")#

       

       

         

      <cfparam name="Form.startdate" default="#dateformat(now(), 'mm/dd/yyyy')#"> 
              <cfparam name="Form.enddate" default="#dateformat(now()+1, 'mm/dd/yyyy')#"> 
              <cfparam name="Form.selectdate" default="#dateformat(now(), 'mm/dd/yyyy')#"> 
          </div>
      
          <span class="label label-default">Equipment List</span>
          <table class="table table-bordered table-striped">
              <tr>
                  <td><b>Select</b></td>    
                  <td><b>Name</b></td>
                  <td><b>Description</b></td>
                  <td><b>Status</b></td>
              </tr>
          <cfloop query = "equips">
              
              <tr>
                  <td>
                      #checkBox(objectName="reqequip", property="#serial#", defaultValue="#serial#", label="")#
                      #hiddenField(objectName="reqequip", property="#serial#", label="")#
                      <!---<input type="checkbox" name="status"  value="#serial#">Select:
                      <cfinput name="serial"type="text"style="display:none" value="#serial#">
                      <cfinput name="name"type="text"style="display:none" value="#name#">--->
                  </td>    
                  <td>#equips.name#</td>
                  <td>#equips.descrip#</td>
                  <td>#equips.status#</td>
              </tr>
              </cfloop>
      </table>
            <!---<cfinput class="btn btn-default" type="Submit" value="Submit" name="reqequip"></cfinput>--->
            #submitTag(class='btn btn-default')#
          #endFormTag()#
      
      
      </cfoutput>
      

       

       

      Thanks!