default state of hidden field not working with addForm

9 posts by 4 authors in: Forums > CMS Builder
Last Post: April 7, 2010   (RSS)

By markr - April 3, 2010

I have set the default state to "checked" in the admin but when I add records via addForm.php they are not coming in hidden.

Do I have to post a hidden input value in the addForm in order for insertions to default to hidden?

Re: [markr] default state of hidden field not working with addForm

By Jason - April 5, 2010

Hi,

The default state that you set in the admin will work when you are adding records through CMS Builder. If you are using your own form to add a value and you want a check box checked by default, you will need to add that in the code.

For example:

<input type="checkbox" checked />

The option "checked" will set the default state of that checkbox to checked.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] default state of hidden field not working with addForm

By markr - April 5, 2010

I don't want user control over this field so I started with

<input type=hidden name=hidden value=1>

but then woke up and just added

hidden= '1',

to the insertion array.

Thanks.

Re: [markr] default state of hidden field not working with addForm

By Jason - April 5, 2010

I see what you mean. Glad that worked out for you.

Let me know if you have any other questions.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] default state of hidden field not working with addForm

By Deborah - April 6, 2010

I'm facing the same challenge, but don't understand the solution offered here:

but then woke up and just added
hidden= '1',
to the insertion array.


Could someone please provide a more instruction? I'm not familiar with the terminology used. (Not a programmer.)

Thanks in advance for any help.
Deborah

Re: [Deborah] default state of hidden field not working with addForm

By Jason - April 6, 2010

Hi Deborah,

The issue here was setting a checkbox field(named hidden) to be checked by default in CSM Builder. This works fine as long as the records are being added through CMS Builder. If you are using an eternal page to add a record to the database (addForm.php for example) then this default value doesn't carry over.

The solution here was to add the value to the SQL insertion string (hidden='1' is the same as the hidden checkbox being checked).

If you need some more, let me know where your problem is and I can help further.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] default state of hidden field not working with addForm

By Deborah - April 6, 2010

Thanks for your help. I've been trying different methods for the past few hours, but I'm still stuck.


The issue here was setting a checkbox field(named hidden) to be checked by default in CSM Builder. This works fine as long as the records are being added through CMS Builder. If you are using an eternal page to add a record to the database (addForm.php for example) then this default value doesn't carry over.

This I do understand.


The solution here was to add the value to the SQL insertion string (hidden='1' is the same as the hidden checkbox being checked).

I don't understnad how and where to "add the value to the SQL insertion string"?

I tried this in the <head> element:
'where' => "hidden='1' AND obit_name='". mysql_real_escape_string( $_SERVER['QUERY_STRING'] ) ."'",
That returns no results, but could be a semantics issue on my part.

I tried adding in the HTML form:
<input type="hidden" name="hidden" value="1" />
to my form tag, but it seems that has had no effect on the values posted to the database.

In the CMSB editor, I changed the checkbox values from Yes/No to 1/0 in the CMSB field editor, but that didn't help. (The database has always shown these values as 1 and 0 anyway.)

What I want to be able to do is to have the form data post to the database, but not appear on the website until the site owner has indicated the record as approved via a checkbox field. (The form that is posting is from a custom programming job by Interactive Tools.)

I welcome any further suggestions.

Deborah

Re: [Deborah] default state of hidden field not working with addForm

By Kenny - April 6, 2010

Deborah,

One way we have done it in the past is to have a field where you must place a check in the box in order to approve it.

Instead of "Hidden" call it is "Status"

Checked = Approved
Unchecked = Unapproved

When the form is submitted, it will by default be unchecked.

Then on your viewer page, only display the listings that are approved by using a where statement or an if statement ike this:

<?php if ($record['status']): ?>
DISPLAY RESULTS HERE
<?php endif ?>

Let me know if that helps or if you have any questions.

Kenny