A
A
Alexander Ivanov2017-04-23 17:56:55
PHP
Alexander Ivanov, 2017-04-23 17:56:55

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');
  }
}

The author of the plug-
in At the output it turns out, the saving goes on, but, as if, it transfers the values ​​​​to a string, although getTVValue should do this, maybe then it is somehow more difficult to create a plug-in?
those. checkboxes are not marked as active from the admin side. From the conversation, it is not clear whether the guys had problems with saving in the admin panel or not.
This is how I display tags in tpl.Tickets.form.create:
<select name="tegs[]" class="form-control" id="ticket-tegs" multiple>
  
  </select>

This is how TV retrieves the tags:
@EVAL return $modx->runSnippet('pdoMenu',array('parents'=>5,'tplOuter'=>'@INLINE ','tpl'=>'@INLINE ==<span><a href="/"></a></span>||'));

Maybe this can help me:
How to get the value of tv, not as a string but as data (in the format in which they are stored)?
- the answer is here
Apparently the tv values ​​are stored as strings. Apparently I'm not passing them correctly...
____________________________
Now I'm trying differently
True, this time tv is not displayed
, although the documentation for tiketsForm says "You can add tv" and I display not a single example with added tv
like this:


// в 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 question

Ask a Question

731 491 924 answers to any question