We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36735
    • 18 Posts
    I have a web context page with a form. It uses FormIt, Formit2db, db2FromIt, and FormItRetriever.

    Every thing saves to the db properly and pulls from the database properly EXCEPT when I want to store modx placeholder tags.

    I;m using a textarea field with summernote.js as a WYSIWYG editor. The validate on Formit does allowTags. All the HTML gets saved to the DB, but any placeholder that I use does not.

    [[!FormIt?
      		&preHooks=`db2FormIt`
    		&paramname=`scriptid`
    		&fieldname=`id`
    		&hooks=`Formit2db`
    		&successMessage=`<div class="alert alert-success alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><p class=""><i class="fa fa-thumbs-o-up fa-fw"></i> Successfully submitted form id.</p></div>`
            &prefix=`crm_`
            &packagename=`crm`
    		&where=`{"id":[[!+fi.scriptid:eq=``:then=`[[!+fi.id]]`:else=`[[!+fi.scriptid]]`]]}`
            &errTpl=`<span class="label label-danger">[[+error]]</span>`
            &classname=`MerchantScripts`
            &tablename=`MerchantScripts`
    		&validate=`script_name:required,
    		description_long:allowTags`
    		&store=`1`
    		&storeTime=`10`
    	 ]]
    	 [[!FormItRetriever]]
         <form method="post" action="[[~[[*id]]]]?scriptid=[[!+fi.scriptid:eq=``:then=`[[!+fi.id]]`:else=`[[!+fi.scriptid]]`]]" role="form">
    
    <textarea class="form-control" rows="3" name="description_long" placeholder="">[[!+fi.description_long]]</textarea>
    
    ...
    </form>


    Here is the sample HTML I am trying to store in the DB:

    <p>Hello [[+lead.firstname]],</p>
    <p>How are you today?</p>
    


    Everything except [[+lead.firstname]] is stored the db. Is there a way to do this? This peive of HTML is later used and there iis a valid snippet call the uses the placeholder, but since this never gets stored in the db, I can;t move forward.

    Anyone else come across a solution for this?
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Where is the [[+lead.firstname]] coming from? Is there a form getting saved somewhere, if so you could use a hidden field with [[+lead.firstname]] for its value, and the form handling could then save it like any other form field.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 36735
        • 18 Posts
        the [[+lead.firstname]] does not do anything on the form. What I want to do is store the entire html block into a db field like a chunk. And within a chunk you can save placeholders to be used in toArray().

        The form is actually like a "pseudo front end admin". I create and edit the object using formit. Call it a "MerchantScript".

        Then later getObject() on the "MerchantScripts". Put the object into placeholder with prefix lead. And when It displays the script to a user, someone who is going to speak it (not within the create//edit form), I want to fill in the placeholder data.

        It might be a bit confusing. Hope that makes sense? So [[+lead.firstname]] is being stored in the db so it can be called later (outside of the form).

        Resource 1 = Form with fields to save object into "MerchantScripts" table. One of those fields is a mysql text field and I store html and this place holder.

        Resoiurce 2 = User Script which display the MerchantScripts object as HTML. There is a snippet inside of that resource which pulls a $_GET['scriptid'] to display the correct Object to the user. During this process is when I would use getObject() and toPlaceholder().

        Just can't save the placeholder to to the DB. sad (not the value of the placeholder but the literal tag itself will not save, its like it gets stripped out during form processing)