I'm making a component for Joomla 2.5 and according to the docs there is a form folder and in it a xml file:
<field
name="id"
type="hidden"
/>
<field
name="greeting"
type="text"
label="COM_HELLOWORLD_HELLOWORLD_GREETING_LABEL"
description="COM_HELLOWORLD_HELLOWORLD_GREETING_DESC"
size="40"
class="inputbox"
default=""
/>
I need for a field to be a checkbox, so I changed type="text" to "checkbox" which is fine for adding a new entry. But with editing I need to check the value from a database to see if the checkbox is selected or not. So for example, I'll have something like this:
<field
name="published"
type="checkbox"
label="COM_HELLOWORLD_HELLOWORLD_GREETING_LABEL"
description="COM_HELLOWORLD_HELLOWORLD_GREETING_DESC"
size="40"
class="checkbox"
default=""
/>
and if 'published' in the database is 1, I want the default checkbox to be selected. Is there anyway to do that? Thanks!
You can do this by using the default input field in edit.php
.This help me,it may also help you.
For example:
<?php
if($this->form->getValue('published')==1)
{
$value=1;
}
else{
$value=0;
}?>
<li><?php echo $this->form->getLabel('published'); ?>
<input type="text" name="jform[published]" value="<?php echo $value; ?>" /></li>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.