Adding a checkboxes to the form Events Module

zxc

 

Hi,

 

I have a problem and for a long time, I can not solve it - it's Events module, and more specifically the form.

I need to be able to add checkboxes on the form to add events.

In the database table bx_events_main created a new column "Check" type Varchar (50).

 

The File: Dolphin-v.7.0.9 \ modules \ BoonEx \ events \ classes \ BxEventsFormAdd.php

------- CODE ----------

'Check' => array(
                    'type' => 'checkbox',
                    'name' => 'Check',
                    'caption' => _t('_bx_events_caption_check'),
                    'value' => 'on',
                    'required' => false,
                    'db' => array (
                        'pass' => 'Xss',
                    ),                  
                ),


----- END CODE ------

 

and added to the file: Dolphin-v.7.0.9 \ modules \ BoonEx \ events \ classes \ BxEventDB.php

 

----- CODE -------

$this->_sFieldCheck = 'Check';

----- END CODE -----

 

And everything would be OK - because when you add Events - Check column write the desired value of the course if the user selects the checkbox or not be recorded if you do not mark anything.

Unfortunately, when editing the event, if you select the checkbox when you add it in the edition is awarded - after re-checked - no longer writes a column value of the selected checkbox Check-in.

I ask for support because they are generally poorly described in Dolphin, checkboxes, and this issue is already beginning to overwhelm me.

Please help, for which thank you in advance.

Regards,

seo9

Quote · 16 May 2012

Not sure what you are asking for but try removing this from form

'value' => 'on',

This should stop putting default value

so much to do....
Quote · 16 May 2012

Unfortunately it did not help.

Maybe I'll explain again what I mean.

I want when a user adds an event the user can select a checkbox option in the event.

And my modification works OK - when an event is created and the checkbox is selected - the value of HE is sent to a database table bx_events_main and specifically to the column "Check". If you do not select this checkbox in the Check column remains blank.

Unfortunately, if you want to edit an event, regardless of whether you add the event marked a checkbox or not this is always unchecked checkbox.

As I looked at the Mozilla FF Developer Tools when editing event there is:

--code--

<td class="value">

  <div class="clear_both"></div>

  <div class="input_wrapper input_wrapper_checkbox">

    <input class="form_input_checkbox" type="checkbox" name="4wd" value="">

    <div class="input_close input_close_checkbox"></div>

  </div>

  <div class="clear_both"></div>

</td>

--end code--

As you can see there is Value="" and should be Value="on" - as I think.

 

When editing the event:

First, there are unchecked checkboxes that were selected when adding the event, and secondly, after you select the checkboxes and submit form - the database all previous values (only checkboxes values) are overwritten with a blank - I mean - where the value was already "ON" after clicking on the Submit overwritten them as " ".

PS. Sorry for my poor English, if something is unclear, I will try to explain

Quote · 16 May 2012

well, not sure why it isn't working or is that even supposed to work either but if you want that checkbox checked by default everytime you can add this in the array

'attrs' => array(

         'checked' => 'checked',

),

just after required

so much to do....
Quote · 16 May 2012

No i don`t want like that.

 

I want to:

"values" of checkboxes:

when adding and editing has always value="on"

 

"checked" of checkboxes:

when adding events - all are unchecked. The user can select what he wants.

when editing - selected are checkboxes only those that are selected by user when he adding events.

when editing - unselected checkboxes (are usnelected) but value="on" (now is value="" and after submit current row is overwrited by " " [So nothing happens after checked and submit] )

 

 

Quote · 16 May 2012

You can set the checkboxes to default checked in the associated db table's Structure... so when a new event is added to the db the checkboxes are initially set to be all checked.  Any changes made during the creation or editing of the specific event will stay with that event's setup.

 

Be sure to backup your database before making any changes.

http://pkforum.dolphinhelp.com
Quote · 16 May 2012

 

Guys, I want to run normally checkboxes.

 

So in adding an event proces checkboxes are unchecked - a user selects only those that interest him.

When he edits the event - marked checkboxes when he adding event are checked.

He can also select additional checkboxes or uncheck the previously checked checkboxes.

 

That is as it should be normal.

 

I managed to solve this problem:

 

In BxEventsFormAdd on line 31 added:

 

--code--

$result55 = mysql_query("SELECT * FROM bx_events_main WHERE ID = '$iEntryId' ");

 while($row = mysql_fetch_array($result55)) {
 if ($row['4wd'] == 'on')

{$wd4 = 'on';}

else 

{$wd4 = 'false';}

if ($row['Abs'] == 'on')

{$Abs = 'on';}

else 

{$Abs = false;}

if ($row['Alu'] == 'on')

{$Alu = 'on';}

else 

{$Alu = false;}

}

--end--

 

Thanks to this piece of code, it can check in the database if checkbox is checked or not, and:

if checkbox '4wd'  is checked so $wd4 = 'on'  else false

if checkbox 'Abs' is checked so $Abs = 'on' else false

if checkbox 'Alu' is checked so $Alu = 'on' else false

 

In my form checkboxes looks like that:

-- code --

'4wd' => array(

                    'type' => 'checkbox',

                    'name' => '4wd',

                    'value' => 'on',

'checked' => $wd4,

'caption' => _t('_bx_events_caption_4wd'),

                    'required' => false,

                     'db' => array (

                        'pass' => 'Xss',

                    ),

),

 'Abs' => array(

                    'type' => 'checkbox',

                    'name' => 'Abs',

                    'value' => 'on',

'checked' => $Abs,

'caption' => _t('_bx_events_caption_abs'),

                    'required' => false,

                    'db' => array (

                        'pass' => 'Xss',

                    ), 

),

 'Alu' => array(

                    'type' => 'checkbox',

                    'name' => 'Alu',

                    'caption' => _t('_bx_events_caption_alu'),

                    'required' => false,

'value' => 'on',

'checked' => $Alu,

                    'db' => array (

                        'pass' => 'Xss',

                    ), 

),

-- end --

As you can see in every checkbox in 'checked' is $wd4, $Abs or $Alu - so it work like charm.

When I edit event checkboxes alredy checked in add an event proces are checked.

But unfortunately there is the last thing that does not work - unchecked checkboxes always have the value=" " - (blanc value) and here is the real problem for me.

The question is:

How do I get value="on" always.

 

Quote · 17 May 2012

How do I get checkbox value="on" alway irrespective of whether it is checked or not ?

Quote · 19 May 2012

Try to edit this

$result55 = mysql_query("SELECT * FROM bx_events_main WHERE ID = '$iEntryId' ");
while($row = mysql_fetch_array($result55)) {

if ($row['4wd'] = 'on')
{$wd4 = 'checked';}
else
{$wd4 = 'false';}


if ($row['Abs'] = 'on')
{$Abs = 'checked';}
else
{$Abs = false;}


if ($row['Alu'] = 'on')
{$Alu = 'checked';}
else
{$Alu = false;}
}

Quote · 19 May 2012
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.