Answer the question
In order to leave comments, you need to log in
How to pass state of checkboxes from frontend to ticketsForm?
The essence of the problem is that in the admin panel, checkboxes are not marked (active), but the output is just a string.
The plugin itself:
if($mode == 'new' && $resource->class_key == 'Ticket' && $modx->event->name == 'OnDocFormSave'){
$tegs = implode("||", $_POST['tegs']);
if (!$resource->setTVValue('tegs', $tegs)) {
$modx->log(xPDO::LOG_LEVEL_ERROR, 'tegs - ERROR');
}
}
<select name="tegs[]" class="form-control" id="ticket-tegs" multiple>
</select>
@EVAL return $modx->runSnippet('pdoMenu',array('parents'=>5,'tplOuter'=>'@INLINE ','tpl'=>'@INLINE ==<span><a href="/"></a></span>||'));
// в tpl.Tickets.form.create
<select name="tegs[]" class="form-control" id="ticket-tegs" multiple>
</select>
//сниппет
<?php
$tv = $modx->getObject('modTemplateVar', array('name' => $name));
$elements = $tv->get('elements');
$element = explode('||', $elements);
foreach($element as $e) {
list($elName,$elId) = explode("==", $e);
if ($elId == $input) {
$selected = ' selected="selected"';
} else {
unset($selected);
}
echo '<option value="'.$elId.'"'.$selected.'>'.$elName.'</option>';
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question