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: [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

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

By Deborah - April 7, 2010

Kenny,

Your solution worked for me! Thanks so much for posting. (I'm still learning to work with PHP and without this forum, I'd be lost!)

Not sure why the 'hidden' field name wasn't working as opposed to the unique field name, but ah, well.

Thanks again.
Deborah