Announcement

Collapse
No announcement yet.

the field value is written into database even when the block is hidden

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • the field value is written into database even when the block is hidden

    I have a block contains several fields in it. What I do is I entered some values on those fields and then I hide the whole block using sc_block_display. I found even i hided the blocks but the fields are being inserted into the database. Is there a way to prevent this happening?

  • #2
    Not really, all fields that in the screen that are connected to a table field will be inserted/updated into the table, even if hidden.
    I dont see a way to change that apart from hacking the generated code.

    Comment


    • #3
      Thanks rr for your reply. But it sounds stupid that the reason of hiding a block is to prevent user from entering unnecessary data to the database. but now the user has to clear the wrongly entered fields manually and then select the appropriate block for completing the form. I think scriptcase has to really look into this issue.

      Comment


      • #4
        No I don't think so as you don't understand the concept. It's no issue if the field is retrieved from the database and rewritten unchanged. The fields involved are in your own sql section. If you need to retrieve different data depending on different status you simply need to design your application differently. One solution might be that you save the fields on the block to be hidden in the onload event and rewrite them back when the section is hidden by the ajax event or in the onvalidate where you check if the block is hidden.
        Albert Drent
        aducom software netherlands
        scriptcase partner, reseller, support and (turn-key) development
        www.scriptcase.eu / www.scriptcase.nl

        Comment


        • #5
          Sorry Albert i think i didn't made myself clear. I am working on a registration form which is only plain "Insert" to a table. there is a Yes/No radio field that if the user click "Yes" then Block A shows while user click "No" it shows Block B with different fields to enter. The case is, if a user first clicked "Yes" and entered the fields on Block A, but then he/she changed the mind and click "NO" later on and then go for Block B and save it finally. Scriptcase writes the fields on both Block A and Block B to the tables. Well it can be solved by assigning empty values on all text fields in a hidden block, but it gets complicated when the field is radio or other kind of fields such as file upload. Is there a more systematic way to handle the issue of dynamic form fields in scriptcase? please help
          Last edited by wowwow9; 01-22-2015, 06:15 AM.

          Comment


          • #6
            I understood you well. If you need to be fully dynamic then I suggest you use a control application. Then you can create the right sql for the different situations. Disadvantage is that you need to create the form by hand, but you have the maximum flexibility. In your case I would test the checkboxvalue in the onvalidate and reset the entered data which is not valid.
            Albert Drent
            aducom software netherlands
            scriptcase partner, reseller, support and (turn-key) development
            www.scriptcase.eu / www.scriptcase.nl

            Comment


            • #7
              Thanks for your suggestion Albert, will try that out!
              Last edited by wowwow9; 01-22-2015, 12:57 PM.

              Comment


              • #8
                Just an update on my finding if some would find it useful in future, if a field is sc_field_disabled(), the value on that field is being discarded and a blank value is written to the database for that field.

                Comment

                Working...
                X