advcheckbox в QuickForm

idencial

Одинаковый
advcheckbox в QuickForm

при создании advcheckbox элемента в QuickForm
PHP:
$form->addElement('advcheckbox', 'show', 'Show');
Выводит
PHP:
<input name="__show" type="checkbox" value="1" id="qf_6f99a4" checked="checked" onclick="if (this.checked) { this.form['show'].value='1'; }else { this.form['show'].value=''; } " /><input type="hidden" name="show" value="1" />
А можно сделать так, чтобы когда он не отмечен было не '', а 0?
 

Sad Spirit

мизантроп (Старожил PHPClub)
Команда форума
блин, а самому посмотреть?
PHP:
$form->addElement('advcheckbox', 'show', 'Show', null, array(0, 1));
 

idencial

Одинаковый
Извини, тормознул

-~{}~ 12.10.04 01:59:

Блин, а теперь на
PHP:
$form->addElement('advcheckbox', 'show', 'Show', null, array(0, 1));
он выводит
PHP:
<input 0="0" 1="1" name="__show" type="checkbox" value="1" id="qf_e0701e" onclick="if (this.checked) { this.form['show'].value='1'; }else { this.form['show'].value=''; } " /><input type="hidden" name="show" value="" />
Баг или я торможу?
 

Sad Spirit

мизантроп (Старожил PHPClub)
Команда форума
Виноват:
PHP:
$form->addElement('advcheckbox', 'show', 'Show', null, null, array(0, 1));
 

idencial

Одинаковый
Спасибо, на этот раз все правильно
Только интересно почему в мане
PHP:
void constructor HTML_QuickForm_advcheckbox::HTML_QuickForm_advcheckbox ([string $elementName = NULL [, string $elementLabel = NULL [, string $text = NULL [, mixed $attributes = NULL [, mixed $values = NULL]]]]])
+ в самом классе
PHP:
function HTML_QuickForm_advcheckbox($elementName=null, $elementLabel=null, $text=null, $attributes=null, $values=null)
    {
        $this->HTML_QuickForm_checkbox($elementName, $elementLabel, $text, $attributes);
        $this->setValues($values);
    }
Значения идут как пятый атрибут, а срабатывает правильно когда указываешь их как шестой.
 

Sad Spirit

мизантроп (Старожил PHPClub)
Команда форума
Автор оригинала: idencial
Значения идут как пятый атрибут, а срабатывает правильно когда указываешь их как шестой.
Патамушта в документации написано:
Adds an element into the form. If $element is a string representing an element type, then this method accepts variable number of parameters, their meaning and count depending on element type.

Parameters starting from second will be passed to the element's constructor, consult the docs for the appropriate element to find out which parameters to pass.
соответственно 2--6 параметры addElement() == 1--5 параметры конструктора.
 
Сверху