LostAvatar
LostAvatar

Reputation: 794

Joomla checkbox doesn't update database

I'm using Joomla 2.5 and have a problem while fooling aroung with my first component.

I use the following fieldset in a form:

<fieldset>      
    <field
        name="person_id"
        type="hidden"
    />
    <field
        name="person_email"
        type="text"
        label="Email"
        description="Email"
        size="40"
        class="inputbox"
        default=""
    />
    <field
        name="person_notification"
        type="text"
        label="Notification"
        description="Notification"
        class="checkbox"
    />
</fieldset>

The email field is working as expected and updates the database entry. The notification field is making me trouble. The value is not set.

I have read about this issue here and here. I tried to adapt the method 2 from the second link, but it didn't help me. The code I tried was:

<fieldset>      
    <field
        name="person_id"
        type="hidden"
    />
    <field
        name="person_email"
        type="text"
        label="Email"
        description="Email"
        size="40"
        class="inputbox"
        default=""
    />
    <input type="hidden" name="jform[person_notification]" value="0" />
    <input type="checkbox" name="person_notification" class="inputbox" />
</fieldset>

The checkbox is not visible at all in this case, because in my edit.php I use

<?php foreach($this->form->getFieldset() as $field): 
   if ($field->label!="") {
       echo '<li>'.$field->label.$field->input.'<br/></li>';
   } else {
       echo '<li>'.$field->input.'</li>';             
   }?>

So I think I have to adapt method 2 to use field tags, but I don't know how to do this. Can anybody tell me, how I have to define my filedset to get this working? I have read this SO question, but I am not sure, whether this is exactly the problem I am experiencing.

I am aware of the possibility to use radio buttons, but my requirements don't allow this workaround. Changing anything in the core joomla code or updating to version 3 is also no valid possibility in my case.

Upvotes: 1

Views: 437

Answers (1)

S&#248;ren Beck Jensen
S&#248;ren Beck Jensen

Reputation: 1676

I can't see anything wrong.

Try replicating the functionality using the Joomla Component Creator http://www.component-creator.com and see what the difference is.

Upvotes: 1

Related Questions