Мне нужно, чтобы каждый из флажков был предварительно выбран в ValidForm Builder на основе их значений по умолчанию, если они были выбраны при первоначальной записи записи в таблицу БД.
Вот мой код:
$objType = $objGroup->addField('locationType', 'Location Type', VFORM_CHECK_LIST,
array('required' => true),
array('required' => 'Location Type is required'),
array(
'fieldclass' => 'vf__inlineButtons',
'tip' => (($_SESSION['auth']['tips'] && $_POST['action'] != 'delete') ? VFB_TIP_LOCATIONS_LOCATIONTYPE : NULL),
(($_POST['action'] == 'delete') ? 'fieldDisabled' : 'fieldEnabled') => (($_POST['action'] == 'delete') ? 'disabled' : 'enabled'),
'default' => $default['locationType']
)
);
$objType->addField('Destination', 'D');
$objType->addField('Sales', 'S');
$objType->addField('Pickup/Dropoff', 'P');
$objType->addField('Both, Sales & Pickup/Dropoff', 'B');
Вот мои попытки проб и ошибок заставить его работать:
( 1) Я удалил 'default' => $default['locationType'] и добавил 'checked' к каждому $objType->addField(). Итак, в приведенном выше коде ко всем четырем элементам $objType->addField() добавлен элемент «checked». В результате проверяется только последний флажок — нет успеха.
(2) Я удалил «default» => $default[' locationType'] и добавил 'selected' к каждому $objType->addField(). Итак, в приведенном выше коде ко всем четырем элементам $objType->addField() добавлен элемент «selected». В результате проверяется только последний флажок — нет успеха.
(3) Я удалил «default» => $default[' locationType'] и добавил 'checked' => 'checked' к каждому $objType->addField(). Итак, в приведенном выше коде ко всем четырем элементам $objType->addField() добавлен элемент 'checked' => 'checked'. В результате скрипт ничего не генерирует -- безуспешно.
(4) Я тоже это пробовал - 'default' => array(" D", "", "P", "") -- безуспешно.
(5) Я попробовал это -- 'default' => array(true, false, true, false) -- все флажки проверяются -- нет успеха.
(6) Я попробовал это -- 'default' => array("1", "0", "1", "0") -- проверяется только первый флажок -- < strong>безуспешно.
(7) Я попробовал это -- 'default' => array(1, 0, 1, 0) -- проверяется только первый флажок -- нет успеха.
Я думаю, что ValidForm Builder не готов к установке флажков.
Вот соответствующий код VFB (если он поможет вам понять, в чем проблема). ПРИМЕЧАНИЕ. 22 февраля 2014 г., благодаря моему расширенному устранению неполадок T&E, я не верю, что этот файл класса вообще загружается или используется при создании HTML. Продолжаем копать...:
class VF_Checkbox extends VF_Element {
public function toHtml($submitted = FALSE, $blnSimpleLayout = FALSE, $blnLabel = true, $blnDisplayErrors = true) {
$blnError = ($submitted && !$this->__validator->validate() && $blnDisplayErrors) ? TRUE : FALSE;
if (!$blnSimpleLayout) {
//*** We asume that all dynamic fields greater than 0 are never required.
if ($this->__validator->getRequired()) {
$this->setMeta("class", "vf__required");
} else {
$this->setMeta("class", "vf__optional");
}
if ($blnError) $this->setMeta("class", "vf__error");
if (!$blnLabel) $this->setMeta("class", "vf__nolabel");
// Call this right before __getMetaString();
$this->setConditionalMeta();
$strOutput = "__getMetaString()}>\n";
if ($blnError) $strOutput .= "
{$this->__validator->getError()}
";
if ($this->__getValue($submitted)) {
//*** Add the "checked" attribute to the input field.
$this->setFieldMeta("checked", "checked");
} else {
//*** Remove the "checked" attribute from the input field. Just to be sure it wasn't set before.
$this->setFieldMeta("checked", null, TRUE);
}
if ($blnLabel) {
$strLabel = (!empty($this->__requiredstyle) && $this->__validator->getRequired()) ? sprintf($this->__requiredstyle, $this->__label) : $this->__label;
if (!empty($this->__label)) $strOutput .= "__getLabelMetaString()}>{$strLabel}\n";
}
} else {
if ($blnError) $this->setMeta("class", "vf__error");
$this->setMeta("class", "vf__multifielditem");
// Call this right before __getMetaString();
$this->setConditionalMeta();
$strOutput = "__getMetaString()}>\n";
if ($this->__getValue($submitted)) {
//*** Add the "checked" attribute to the input field.
$this->setFieldMeta("checked", "checked");
} else {
//*** Remove the "checked" attribute from the input field. Just to be sure it wasn't set before.
$this->setFieldMeta("checked", null, TRUE);
}
}
$strOutput .= "__getFieldMetaString()}/>\n";
if (!empty($this->__tip)) $strOutput .= "{$this->__tip}\n";
$strOutput .= "\n";
return $strOutput;
}
public function toJS() {
$strOutput = "";
$strCheck = $this->__validator->getCheck();
$strCheck = (empty($strCheck)) ? "''" : str_replace("'", "\\'", $strCheck);
$strRequired = ($this->__validator->getRequired()) ? "true" : "false";;
$intMaxLength = ($this->__validator->getMaxLength() > 0) ? $this->__validator->getMaxLength() : "null";
$intMinLength = ($this->__validator->getMinLength() > 0) ? $this->__validator->getMinLength() : "null";
$strOutput .= "objForm.addElement('{$this->__id}', '{$this->__name}', {$strCheck}, {$strRequired}, {$intMaxLength}, {$intMinLength}, '" . addslashes($this->__validator->getFieldHint()) . "', '" . addslashes($this->__validator->getTypeError()) . "', '" . addslashes($this->__validator->getRequiredError()) . "', '" . addslashes($this->__validator->getHintError()) . "', '" . addslashes($this->__validator->getMinLengthError()) . "', '" . addslashes($this->__validator->getMaxLengthError()) . "');\n";
//*** Condition logic.
$strOutput .= $this->conditionsToJs();
return $strOutput;
}
public function getValue($intDynamicPosition = 0) {
$varValue = parent::getValue($intDynamicPosition);
return (strlen($varValue) > 0 && $varValue !== 0) ? TRUE : FALSE;
}
public function getDefault($intDynamicPosition = 0) {
return (strlen($this->__default) > 0 && $this->getValue($intDynamicPosition)) ? "on" : null;
}
}
Подробнее здесь: https://stackoverflow.com/questions/219 ... rm-builder
Как сделать так, чтобы флажки проверялись в ValidForm Builder? ⇐ Php
Кемеровские программисты php общаются здесь
-
Anonymous
1729222334
Anonymous
Мне нужно, чтобы каждый из флажков был предварительно выбран в ValidForm Builder на основе их значений по умолчанию, если они были выбраны при первоначальной записи записи в таблицу БД.
Вот мой код:
$objType = $objGroup->addField('locationType', 'Location Type', VFORM_CHECK_LIST,
array('required' => true),
array('required' => 'Location Type is required'),
array(
'fieldclass' => 'vf__inlineButtons',
'tip' => (($_SESSION['auth']['tips'] && $_POST['action'] != 'delete') ? VFB_TIP_LOCATIONS_LOCATIONTYPE : NULL),
(($_POST['action'] == 'delete') ? 'fieldDisabled' : 'fieldEnabled') => (($_POST['action'] == 'delete') ? 'disabled' : 'enabled'),
'default' => $default['locationType']
)
);
$objType->addField('Destination', 'D');
$objType->addField('Sales', 'S');
$objType->addField('Pickup/Dropoff', 'P');
$objType->addField('Both, Sales & Pickup/Dropoff', 'B');
[b]Вот мои попытки проб и ошибок заставить его работать:[/b]
( 1) Я удалил 'default' => $default['locationType'] и добавил 'checked' к каждому $objType->addField(). Итак, в приведенном выше коде ко всем четырем элементам $objType->addField() добавлен элемент «checked». В результате проверяется только последний флажок — [b]нет успеха[/b].
(2) Я удалил «default» => $default[' locationType'] и добавил 'selected' к каждому $objType->addField(). Итак, в приведенном выше коде ко всем четырем элементам $objType->addField() добавлен элемент «selected». В результате проверяется только последний флажок — [b]нет успеха[/b].
(3) Я удалил «default» => $default[' locationType'] и добавил 'checked' => 'checked' к каждому $objType->addField(). Итак, в приведенном выше коде ко всем четырем элементам $objType->addField() добавлен элемент 'checked' => 'checked'. В результате скрипт ничего не генерирует -- [b]безуспешно[/b].
(4) Я тоже это пробовал - 'default' => array(" D", "", "P", "") -- [b]безуспешно[/b].
(5) Я попробовал это -- 'default' => array(true, false, true, false) -- все флажки проверяются -- [b]нет успеха[/b].
(6) Я попробовал это -- 'default' => array("1", "0", "1", "0") -- проверяется только первый флажок -- < strong>безуспешно.
(7) Я попробовал это -- 'default' => array(1, 0, 1, 0) -- проверяется только первый флажок -- [b]нет успеха[/b].
Я думаю, что ValidForm Builder не готов к установке флажков.
[b]Вот соответствующий код VFB (если он поможет вам понять, в чем проблема). ПРИМЕЧАНИЕ. 22 февраля 2014 г., благодаря моему расширенному устранению неполадок T&E, я не верю, что этот файл класса вообще загружается или используется при создании HTML. Продолжаем копать...:[/b]
class VF_Checkbox extends VF_Element {
public function toHtml($submitted = FALSE, $blnSimpleLayout = FALSE, $blnLabel = true, $blnDisplayErrors = true) {
$blnError = ($submitted && !$this->__validator->validate() && $blnDisplayErrors) ? TRUE : FALSE;
if (!$blnSimpleLayout) {
//*** We asume that all dynamic fields greater than 0 are never required.
if ($this->__validator->getRequired()) {
$this->setMeta("class", "vf__required");
} else {
$this->setMeta("class", "vf__optional");
}
if ($blnError) $this->setMeta("class", "vf__error");
if (!$blnLabel) $this->setMeta("class", "vf__nolabel");
// Call this right before __getMetaString();
$this->setConditionalMeta();
$strOutput = "__getMetaString()}>\n";
if ($blnError) $strOutput .= "
{$this->__validator->getError()}
";
if ($this->__getValue($submitted)) {
//*** Add the "checked" attribute to the input field.
$this->setFieldMeta("checked", "checked");
} else {
//*** Remove the "checked" attribute from the input field. Just to be sure it wasn't set before.
$this->setFieldMeta("checked", null, TRUE);
}
if ($blnLabel) {
$strLabel = (!empty($this->__requiredstyle) && $this->__validator->getRequired()) ? sprintf($this->__requiredstyle, $this->__label) : $this->__label;
if (!empty($this->__label)) $strOutput .= "__getLabelMetaString()}>{$strLabel}\n";
}
} else {
if ($blnError) $this->setMeta("class", "vf__error");
$this->setMeta("class", "vf__multifielditem");
// Call this right before __getMetaString();
$this->setConditionalMeta();
$strOutput = "__getMetaString()}>\n";
if ($this->__getValue($submitted)) {
//*** Add the "checked" attribute to the input field.
$this->setFieldMeta("checked", "checked");
} else {
//*** Remove the "checked" attribute from the input field. Just to be sure it wasn't set before.
$this->setFieldMeta("checked", null, TRUE);
}
}
$strOutput .= "__getFieldMetaString()}/>\n";
if (!empty($this->__tip)) $strOutput .= "{$this->__tip}\n";
$strOutput .= "\n";
return $strOutput;
}
public function toJS() {
$strOutput = "";
$strCheck = $this->__validator->getCheck();
$strCheck = (empty($strCheck)) ? "''" : str_replace("'", "\\'", $strCheck);
$strRequired = ($this->__validator->getRequired()) ? "true" : "false";;
$intMaxLength = ($this->__validator->getMaxLength() > 0) ? $this->__validator->getMaxLength() : "null";
$intMinLength = ($this->__validator->getMinLength() > 0) ? $this->__validator->getMinLength() : "null";
$strOutput .= "objForm.addElement('{$this->__id}', '{$this->__name}', {$strCheck}, {$strRequired}, {$intMaxLength}, {$intMinLength}, '" . addslashes($this->__validator->getFieldHint()) . "', '" . addslashes($this->__validator->getTypeError()) . "', '" . addslashes($this->__validator->getRequiredError()) . "', '" . addslashes($this->__validator->getHintError()) . "', '" . addslashes($this->__validator->getMinLengthError()) . "', '" . addslashes($this->__validator->getMaxLengthError()) . "');\n";
//*** Condition logic.
$strOutput .= $this->conditionsToJs();
return $strOutput;
}
public function getValue($intDynamicPosition = 0) {
$varValue = parent::getValue($intDynamicPosition);
return (strlen($varValue) > 0 && $varValue !== 0) ? TRUE : FALSE;
}
public function getDefault($intDynamicPosition = 0) {
return (strlen($this->__default) > 0 && $this->getValue($intDynamicPosition)) ? "on" : null;
}
}
Подробнее здесь: [url]https://stackoverflow.com/questions/21914847/how-do-you-get-checkboxes-to-be-checked-in-validform-builder[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия