سؤال

I'm working with Joomla User Form. I need to create some extra fields. I googled, and got this tutorial

I followed but that wasn't enough for me because I have to handle with checkbox and radio button. The following form code didn't save submission data (I mean checked/uncheked).

<input class="inputbox" type="checkbox" name="hasweb" id="hasweb" size="40" value="<?php echo $this->user->get('hasweb');?>" />

But the following is fine when I put any data there.

<input class="inputbox" type="text" name="hasweb" id="hasweb" size="40" value="<?php echo $this->user->get('hasweb');?>" />

I'm novice in Joomla. Please help me.

هل كانت مفيدة؟

المحلول

There is a difference between the value and the checked state with HTML checkbox elements. So if you want to have the checkbox represent the actual choice you have to do something like this:

<input class="inputbox" type="checkbox" name="hasweb" id="hasweb" size="40" value="reallyhasweb" <?php echo $this->user->get('hasweb') == "reallyhasweb" ? 'checked="checked"' : ''; ?>" />

This should place checked="checked" in the HTML when the user has selected the checkbox and will make the checkbox selected.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top