For inline actions it works fine. For named action definitions a reference to a template var uses a copy of that var, like in this failing example (when clicking “edit”, showEdit is not updated, so it will still render the “edit” button):

template agreedImprovements(evaluation : Evaluation, showEditArg : Bool){
  var showEdit := false //showEditArg
  action openEdit(){
    showEdit := true;
    replace( "agreed-improvements" );
    if( !showEdit){
      submit openEdit(){ "edit" }
    } else {
      //inputs here

// form open/closed state has to be passed along with the form data to reconstruct
// since there is no input control associated with it, have to use hidden input
template toggleFormHelper( isEditing: ref Bool ){
  dynamicform[ class = "form-horizontal"
             , role = "form"
             , all attributes ]{
    <input type  = "hidden"
           name  = "isEdit"
           value = isEditing />
      isEditing := getRequestParameter("isEdit") == "true";      
Submitted by Elmer van Chastelet on 4 April 2019 at 12:09

Log in to post comments