protected function adicionaAnexos() { CVar::toArray($this->anexos); //Adicionando anexos foreach ($this->anexos as $anexo) { if (is_array($anexo)) { $attach = Swift_Attachment::fromPath($anexo['path']); $attach->setFilename($anexo['filename']); } else { $attach = Swift_Attachment::fromPath($anexo); } $this->message->attach($attach); } }
public static function optionCk($name, $label, $checked = false, $inline = true, $htmlOptions = array()) { $for = CVar::getItemArr($htmlOptions, 'id', $name); $htmlOptions['class'] = CVar::getItemArr($htmlOptions, 'class', '') . ' optCk'; $ck = static::checkBox('', $checked, array_merge($htmlOptions, ['data-for' => $for])); $label = static::label($label, $for, array('class' => $inline ? 'inline' : '')); $ck .= static::hiddenField($name, $checked); $js = <<<EOJ \$(document).on('change', '.optCk[type=checkbox]', function(){ var checked = \$(this).is(':checked') ? 1 : 0; \$("input[name='"+\$(this).data('for')+"']").val( checked ); } ); EOJ; Yii::app()->clientScript->registerScript('checkUpdate', $js, CClientScript::POS_END); return $inline ? $ck . $label : $label . $ck; }