Thanks Bob for the fix.
All,
I've made a lot of progress. With Formit, FormitFastPack and Formit2Db I've built a large form and am able to update new rows in the database. Without breaking anything. Great.
Now trying to add an Edit facility. Used Bob's Guide again creating a snippet to get a specific row and if not POSTed simply call the previously used Formit/Formitfastpack chunk to display the Form but with values from the database.
Not going well. Form appears but values are blank.
Was using a line like this
$output = $modx->getChunk('meetingRoomFormIt',$booking->toArray() ); // attempt to populate form but perhaps db2formit will do this?
Where $booking contains the database row (which I know is populated). But as my comment suggests I now think that db2formit should handle this. Assuming it is given a where clause to tell it to go get a specific row and then $hook->setValues($formFields); will populate the Form.
But nothing is happening.
1) hints on debugging this kind of thing would be appreciated but I've done this -
return ('Forename: ' . $booking->get('Forename')); and the correct name is being returned so the database read is working. Good.
2) is my where clause correct? see code below ( can't find any examples even close to what I'm trying to do)
3) Will db2formit cope with FormItFastPack. I'm worrying about db2formit expecting to replace a placeholder like value=`[[!+fi.someFieldName]]` or perhaps from the FormItFastPack chunk fieldtypestpl <input ... value="[[+current_value:default=`[[+default]]`]]" .... />
But my hunch is that hook->setValues will do just that: force the input values to the correct value regardless of placeholders.
Code snippet. Not convinced by the where clause.
[[!FormIt? &hooks=`spam,formit2db,email` &submitVar=`submitForm`
&preHooks=`db2formit` &where=`{'id':'336'}` &prefix=`risk_` &packagename=`meetingrooms` &tablename=`meetingroombooking` &classname=`Meetingroombooking` ... ]]
[[!field? &name=`Title` &type=`text` &outer_tpl=`myFieldWrapTpl` ]]
[[!field? &name=`Forename` &type=`text` &class=`required` &outer_tpl=`myFieldWrapTpl` ]]
Summary. Trying to get db2formit and formitfastpack to work via a $modx->getChunk call as per Bob's Guide.
Revo.2.2.10 and latest applicable packages.
Ta Muchly
Stuart
[ed. note: parthian last edited this post 12 years, 9 months ago.]