Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8448743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:30:41+00:00 2026-06-10T10:30:41+00:00

Making a simple component. If I save a new record with the box checked,

  • 0

Making a simple component. If I save a new record with the box checked, it saves fine. If I go back and uncheck a previously checked item it reverts back to checked. I thought it had something to do with a hidden field, played with putting one of those in manually but that didn’t fix it either so took it out.

Here’s where I’m at:
An xml snippet:

<fieldset name="checks">
  <field name="checkbox1"
    type="checkbox"
    label="First Checkbox"
    value="1"
    filter="intval"         
  /> 

   <field name="checkbox2"
    type="checkbox"
    label="Second Checkbox"
    value="1"
    filter="intval"         
  /> 

 ...

</fieldset>

The edit.php file:

<div class="width-45 fltlft">
  <fieldset class="adminform">
    <legend>Checkboxes</legend>
    <ul class="adminformlist">
      <?php foreach ($this->form->getFieldset('checks') as $field): ?>
        <li>
          <?php echo $field->label; ?>
          <?php echo $field->input; ?>
        </li>
      <?php endforeach ?>
    </ul>
  </fieldset>
</div>

Also added this towards the end before the form.token:

<input type="hidden" name="task" id="task" value="completion.edit" />

I tried deleting the value=”1″ in the xml but then I had the opposite problem where the check wouldn’t save at all.

Any ideas?

Thanks!

=============================

Edit:

Model:

<?php
defined( '_JEXEC' ) or die;

jimport('joomla.application.component.modeladmin');

class AssessModelCompletion extends JModelAdmin
{
//tells it what kind of record and the prefix

    public function getTable($type = 'Completion', $prefix = 'AssessTable', $config = array())
    {
        return JTable::getInstance($type, $prefix, $config);
    }

    //Load the data into the edit form
    protected function loadFormData()
    {
        $data = JFactory::getApplication()->getUserState('com_assess.edit.completion.data', array()); //first try to get the data from the session, not db

        if (empty($data)) {
            $data = $this->getItem(); //this gets the data
        }

        return $data;

    }

    //Stores data in a session in case a field is missed
    public function getForm($data = array(), $loadData = true)
    {
        $form = $this->loadForm('com_assess.completion', 'completion', array('control' => 'jform', 'load_data' => $loadData));

        return $form;
    }
}

And table:

<?php 
defined ( '_JEXEC' ) or die;

class AssessTableCompletion extends JTable
{
    public function __construct(&$db)
    {
        parent::__construct('#__tablename_completions', 'completion_id', $db);
    }
}

======================================

References:
https://stackoverflow.com/questions/6964333/joomla-1-6-admin-form-processing-grouped-checkboxes-in-form

Tutorial code is not working any more in Joomla 2.5

http://docs.joomla.org/Developing_a_Model-View-Controller_%28MVC%29_Component_for_Joomla!1.7_-_Part_09#Adding_a_toolbar

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T10:30:43+00:00Added an answer on June 10, 2026 at 10:30 am

    So I had a lot of fields and wanted to simply loop through them in my edit.php field to keep it clean. While all the answers offered were right they weren’t easy to implement – got really messy really quickly, had trouble getting it to work, or couldn’t figure out a cleaner way around it. I chewed on this for awhile and then today came across what is basically a field override.

    The key:

    The standard form field types are located in
    joomla/libraries/joomla/form/fields/. You should not store custom
    fields there, nor should you have to use this path in your own code,
    but the standard types are usually good examples.

    The custom field types that belong to your component are usually
    located in administrator/components//models/fields. You can specify this or another path in your
    code

    So, I copied checkbox.php to models/fields. Then, towards the end of the file I added the empty field before the checkbox tag:

    <input type="hidden" name="'.$this->name.'" id="'.$this->id.'" value="0" /><input type="checkbox" .....
    

    Now, whenever I need a checkbox the empty field is also written. May not be the most efficient solution but simple to implement and can hopefully help someone else.

    [Edit]

    As a note, with every Joomla update you would probably need to compare the versions in the core in case there was a change.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple URL request with code like this: URL url = new
I'm making a simple MVC component for joomla following the hello world tutorial for
so im making a simple box from java and this is the code so
I am making simple grid like game ( grid is matrix 128x128) and matrix
I am making simple connection between two table - first one called users has
Making a simple application, so when the user logs out of Windows, it of
Im making a simple alternative to the default linux system monitor. Im looking to
in making a simple cgi server for a course. To do that in some
I am making a simple timer app. I have a uitable with multiple rows.
I'm making a simple mediaplayer app that downloads a song from a predetermined URL

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.